I've been struggling with this problem for a while now. When I install rJava from R, it takes Java 1.6 instead of 1.8. I am using MAC OS 10.8.5 and these are the steps that I've already done.
I've installed R.
I have both Java 1.6 and 1.8 on my machine.
I've reconfigures R from terminal using: sudo R CMD javareconf -n
.
Here is what the output looks like:
Java interpreter : /usr/bin/java Java version : 1.8.0_25 Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre Java compiler : /usr/bin/javac Java headers gen.: /usr/bin/javah Java archive tool: /usr/bin/jar Non-system Java on OS X
trying to compile and link a JNI progam
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c conftest.c -o conftest.o gcc -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre 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
Then I went on to R and installed rJava package as source like this:
install.packages("rJava", type="source")
and I get to DONE(rJava)
then when I check the version using:
library(rJava) .jinit() .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
I still get 1.6.0_25-b17
instead of 1.8
Please let me know if you know the solution to this.
Open command prompt and enter “java –version”. If installed version number is displayed. 2. On Windows, Java is usually installed in the directory C:/Program Files/Java.
Latest version of rJava has fixed this issue. I installed latest version from site using command
install.packages("rJava",,"http://rforge.net/",type="source")
Now the output by calling jvm is as:
> library(rJava)
> .jinit()
> .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.7.0_75-b13"
Note: I have java 1.7 and 1.6 installed, and not java 1.8
What helped me in this case was 2 things (following advice from here: https://www3.ntu.edu.sg/home/ehchua/programming/howto/JDK_Howto.html)
For this I ran:
$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk1.8.0_201/bin/java" 1
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk1.8.0_201/bin/javac" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/java/jdk1.8.0_201/bin/javaws" 1
followed by
$ sudo update-alternatives --set java /usr/java/jdk1.8.0_201/bin/java
$ sudo update-alternatives --set javac /usr/java/jdk1.8.0_201/bin/javac
$ sudo update-alternatives --set javaws /usr/java/jdk1.8.0_201/bin/javaws
Then I could finally see my java in the alternatives in
sudo update-alternatives --config java
where I selected the newly installed java. Then I ran
sudo R CMD javareconf JAVA_HOME=/usr/java/jdk1.8.0_201/bin/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With