Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sudo R CMD javareconf and R CMD javareconf produce different output with Java 10 #137

Closed
luispuerto opened this issue Mar 27, 2018 · 4 comments

Comments

@luispuerto
Copy link

luispuerto commented Mar 27, 2018

I just posted this in stackoverflow but I don't know if it's something to do with rJava. Perhaps, since it seems that with Java 10 rJava isn't building.


I on macOS 10.13.3 and I just update to java 10 and when I've tried to update R to it I just realize that I get two different outputs if I run R CMD javareconf with or without sudo. If I run with sudo it sticks to Java 9, but if I run without sudo it configures java 10.

Without sudo:

$ R CMD javareconf                                                                        
Java interpreter : /Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home/bin/java
Java version     : 10
Java home path   : /Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home
Java compiler    : /Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home/bin/jar
Non-system Java on macOS

trying to compile and link a JNI program
detected JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
/usr/local/opt/llvm/bin/clang  -I/usr/local/Cellar/r/3.4.4/lib/R/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home/include/darwin  -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include   -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c conftest.c -o conftest.o
/usr/local/opt/llvm/bin/clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -L/usr/local/Cellar/r/3.4.4/lib/R/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home/lib/server -ljvm -L/usr/local/Cellar/r/3.4.4/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /usr/local/Cellar/r/3.4.4/lib/R
override rw-r--r--  root/admin for /usr/local/Cellar/r/3.4.4/lib/R/etc/Makeconf? (y/n [n]) y
override rw-r--r--  root/admin for /usr/local/Cellar/r/3.4.4/lib/R/etc/ldpaths? (y/n [n]) y
Done.

With sudo:

$ sudo R CMD javareconf                                                                   
Java interpreter : /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/java
Java version     : 9.0.4
Java home path   : /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
Java compiler    : /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/javac
Java headers gen.: /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/javah
Java archive tool: /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/jar
Non-system Java on macOS

trying to compile and link a JNI program
detected JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
/usr/local/opt/llvm/bin/clang  -I/usr/local/Cellar/r/3.4.4/lib/R/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/include/darwin  -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include   -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c conftest.c -o conftest.o
/usr/local/opt/llvm/bin/clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -L/usr/local/Cellar/r/3.4.4/lib/R/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/lib/server -ljvm -L/usr/local/Cellar/r/3.4.4/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /usr/local/Cellar/r/3.4.4/lib/R
Done.

The end result of this is: without sudo and in consequence with java 10, rJava doesn't build. With sudo and java 9, rJava build normally.

Does anyone know what is going on?

PS/ I have set $JAVA_HOME to JAVA_HOME="$(/usr/libexec/java_home)" in my zsh and bash profile.

PS2/ just for the sake of having all the info in one place... when building rJava with Java 10 I get the following error:

warning: [options] bootstrap class path not set in conjunction with -source 6
warning: [options] source value 6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 warnings
/usr/bin/javah -d . -classpath . org.rosuda.JRI.Rengine
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home/bin/javah" (-1)
make[2]: *** [org_rosuda_JRI_Rengine.h] Error 2
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
* removing ‘/Users/lpuerto/Library/R/3.x/library/rJava’
* restoring previous ‘/Users/lpuerto/Library/R/3.x/library/rJava’

The downloaded source packages are in
    ‘/private/var/folders/wf/41gjf2mx7m7fmvfd8dr22_5h0000gn/T/RtmpT2kJMY/downloaded_packages’
Warning message:
In install.packages("rJava", repos = "cloud.r-project.org") :
  installation of package ‘rJava’ had non-zero exit status

I've checked and there isn't a javah on /Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home/bin/javah as in Java 9.

@JackHo327
Copy link

JackHo327 commented Apr 4, 2018

Hi @luisspuerto , I also met the same problem here.
I also checked you thread here. Nice post!


Thanks @s-u , I tried that and it is working right now 👍

@s-u
Copy link
Owner

s-u commented Apr 4, 2018

This has been worked around in latest rJava - please try rJava 0.9-10

@s-u s-u closed this as completed Apr 4, 2018
@gsgxnet
Copy link

gsgxnet commented May 10, 2018

rJava 0.9-10 does not install with openjdk 10.0.1 on openSUSE Tumbleweed:

install.packages('rJava',,'http://www.rforge.net/')
Installing package into ‘/home/gsd/R/x86_64-suse-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
versuche URL 'http://www.rforge.net/src/contrib/rJava_0.9-10.tar.gz'
Content type 'application/x-gzip' length 654583 bytes (639 KB)
==================================================
downloaded 639 KB

* installing *source* package ‘rJava’ ...
configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/usr/lib64/jvm/java/bin/java'
archiver    : '/usr/lib64/jvm/java/bin/jar'
compiler    : '/usr/lib64/jvm/java/bin/javac'
header prep.: ''
cpp flags   : '-I/usr/lib64/jvm/java/include -I/usr/lib64/jvm/java/include/linux'
java libs   : '-L/usr/lib64/jvm/java/lib/server -ljvm'
checking whether Java run-time works... yes
checking whether -Xrs is supported... yes
checking whether -Xrs will be used... yes
checking whether JNI programs can be compiled... yes
checking JNI data types... ok
checking whether JRI should be compiled (autodetect)... yes

...

checking for ANSI C header files... yes
checking Java version... 
checking whether  actually works... no
checking whether javah was replaced by javac -h... no
configure: error: one or more Java tools are missing.

...

it should detect that javah is replaced by javac -h

from /etc/os-release:

NAME="openSUSE Tumbleweed"
# VERSION="20180502"

/usr/lib64/jvm/java/bin/java -version

openjdk version "10.0.1" 2018-04-17
OpenJDK Runtime Environment (build 10.0.1+10-suse-1.2-x8664)
OpenJDK 64-Bit Server VM (build 10.0.1+10-suse-1.2-x8664, mixed mode)

@kapelner
Copy link

Ditto on Windows 10 with JDK 10 in RStudio running R 3.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants