我想在MAC OSX(10.10.3)上的R中使用rJava包。系统配置如下:
Haroons-MacBook:~ haroonr$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre
Haroons-MacBook:~ haroonr$ echo $LD_LIBRARY_PATH
/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/server
Haroons-MacBook:~ haroonr$ R CMD javareconf
Java interpreter : /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/bin/java
Java version : 1.7.0_75
Java home path : /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre
Java compiler : /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/../bin/javac
Java headers gen.: /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/../bin/javah
Java archive tool: /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/../bin/jar
Non-system Java on OS X
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
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c conftest.c -o conftest.o
clang -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 -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
/Library/Frameworks/R.framework/Resources/bin/javareconf: line 364: cd: /Volumes/Macintosh: No such file or directory
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.7.0_75.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
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
Haroons-MacBook:~ haroonr$ R --version
R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)
现在每当我在rStudio中运行时:
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.6.0_65-b14-468-11M4833"
这意味着rJava正在使用Java 1.6,但我不想使用1.6。 Java 1.6在后续步骤中产生了问题。如何确保rJava仅使用1.7?
安装的rJava包是0.9-7
答案 0 :(得分:0)
rJava的最新版本(0.9-8)修复了此问题。 我使用命令
从site安装了最新版本install.packages("rJava", "http://rforge.net/", type="source")
现在通过调用jvm输出为:
library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
# [1] "1.7.0_75-b13"