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.
options(java.home="/path/to/java")
? – Steven Beaupréjavareconf -n
does nothing --n
tells it to not make any changes (see R documentation) – Simon Urbanek