如何让rJava 0.9-3与甲骨文的Java 1.7的OS X 10.7.4工作?如何让rJava

2019-05-12 03:37发布

有没有人在那里谁已经设法获得rJava 0.9-3与甲骨文的Java 1.7的OS X 10.7.4工作?

R version 2.15.2 (2012-10-26) -- "Trick or Treat" Platform
x86_64-apple-darwin9.8.0/x86_64 (64-bit)

java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

我同时使用install.packages功能和命令行有R 2.15.2安装安装rJava。 我没有得到任何错误。

$ R CMD INSTALL rJava
* installing to library ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library’
* installing *binary* package ‘rJava’ ...

* DONE (rJava)
$ 

如果我用Java首放1.7首先在名单上,但“上”走1.6,rJava总是启动1.6。

如果我用Java首放1.7第一和关闭1.6,rJava做到这一点:

> library(rJava)
> .jinit()
JavaVM: requested Java version ((null)) not available. Using Java at "" instead.
JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
Error in .jinit() : JNI_GetCreatedJavaVMs returned -1
> 

然而,使用系统功能,R本身认定的Java 1.7。

> system("java -version")
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
> 

1.7是否需要/System/Library/Java/JavaConfig.plist一个特殊的条目?

请问版本目录需要调整为1.7? 这是奇怪的,目前都到了,这同时CurrentJDK映射到1.6与1.7结束

$cd /System/Library/Frameworks/JavaVM.framework/Versions/
$ls -la
total 64
drwxr-xr-x  11 root  wheel  374 Sep 26 10:10 .
drwxr-xr-x  11 root  wheel  374 Nov 26 09:24 ..
lrwxr-xr-x   1 root  wheel   10 Sep 26 10:09 1.4 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 Sep 26 10:09 1.4.2 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 Sep 26 10:09 1.5 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 Sep 26 10:09 1.5.0 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 Sep 26 10:09 1.6 -> CurrentJDK
lrwxr-xr-x   1 root  wheel   10 Sep 26 10:09 1.6.0 -> CurrentJDK
drwxr-xr-x   8 root  wheel  272 Nov 26 09:24 A
lrwxr-xr-x   1 root  wheel    1 Sep 26 10:09 Current -> A
lrwxr-xr-x   1 root  wheel   59 Sep 26 10:09 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents

即使有R CMD javareconf与路径指向1.7文件直接或到/ usr /斌/ java的路径,rJava仍然无法找到或启动Java 1.7中运行。

1.7是否需要JAVA_LD_LIBRARY_PATH变盘?

Makeconf:JAVA = /usr/bin/java
Makeconf:JAVAC = /usr/bin/javac
Makeconf:JAVAH = /usr/bin/javah
Makeconf:JAVA_HOME = /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre
Makeconf:JAVA_LD_LIBRARY_PATH = 
Makeconf:JAVA_LIBS = -framework JavaVM
Makeconf:JAVA_CPPFLAGS = -I$(JAVA_HOME)/include

Makeconf:JAR = /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/bin/jar
Makeconf:JAVA = /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre/bin/java
Makeconf:JAVAC = /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/bin/javac
Makeconf:JAVAH = /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/bin/javah
Makeconf:JAVA_HOME = /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre
Makeconf:JAVA_LD_LIBRARY_PATH = 
Makeconf:JAVA_LIBS = -framework JavaVM
Makeconf:JAVA_CPPFLAGS = -I$(JAVA_HOME)/include

谢谢你的帮助

更新1:

我问这个的统计数据,rosuda-devel的名单上,并收到了来自西蒙Urbanek以下响应。 我不认为Windows和Linux有需要从源代码编译为Java 1.7,因为我们运行此Windows和Linux上,并没有编译rJava同样的问题。 一旦我有机会尝试这个,我马上汇报:

您正在使用的是对系统的Java(这在您的系统是1.6)编译的二进制 -所以,如果你删除Java 1.6,你会打破它。 如果你想使用Java 1.7,你就必须重新配置的R用的Java 1.7和重新编译rJava使用这些设置。 需要注意的是Oracle的Java生活在一个完全不同的地方(/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk)大于系统的Java(/System/Library/Frameworks/JavaVM.framework),所以不能互换。

此外,Oracle的Java 1.7不是一个框架,这是一个很大的混乱,并没有真正专为OS X,所以你必须手工将其设置为像在Linux上设置 - 这是很痛苦的。 此外,它需要覆盖......所以如果你真的想下去了兔子洞,这是对我工作:

 JAVA_LD_LIBRARY_PATH=/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre/lib/server JAVA_LIBS='-L/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre/lib/server -ljvm' JAVA_CPPFLAGS='-I/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/include/darwin' R64 CMD javareconf 

( - > install.packages( “rJava”,类型= '源')R64),然后从源安装rJava。 请注意,这只是64位,因此它只能与64位工作R.

Answer 1:

这对我的作品:

的情况是,我的Java目录没有正确配置。

1)首先运行: sudo R CMD javareconf 。 它应该如下:

Java interpreter : /usr/bin/java
Java version     : 1.7.0_40
Java home path   : /Library/Java/JavaVirtualMachines/jdk1.7.0_40.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
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c conftest.c -o conftest.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk1.7.0_40.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.

2)在R,运行: install.packages("rJava",type='source') 安装时应返回DONE(rJava)。 需要注意的是,我必须设置

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home

当我需要开始R作为根:须藤R.要运行作为普通用户,使用

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre

它发生在我身上,我并没有设置以上的/ usr / bin中/ JAVA *在Java 1.7对应的符号链接(针对1.6版本代替),并得到了所有的挫折来自那里。 链接应该是这样的:(它看起来像只的java,javac的,JAVAH和罐子都需要在R)。

$ ls -l /usr/bin/ja*
lrwxr-xr-x  1 root  wheel  71 Oct  3 11:44 /usr/bin/jar -> /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/jar
lrwxr-xr-x  1 root  wheel  77 Oct  3 12:14 /usr/bin/jarsigner -> /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/jarsigner
lrwxr-xr-x  1 root  wheel  72 Oct  3 11:44 /usr/bin/java -> /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/java
lrwxr-xr-x  1 root  wheel  73 Oct  3 11:42 /usr/bin/javac -> /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/javac
lrwxr-xr-x  1 root  wheel  75 Oct  3 12:15 /usr/bin/javadoc -> /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/javadoc
lrwxr-xr-x  1 root  wheel  73 Oct  3 11:44 /usr/bin/javah -> /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/javah
lrwxr-xr-x  1 root  wheel  73 Oct  3 12:15 /usr/bin/javap -> /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/javap
lrwxr-xr-x  1 root  wheel  74 Oct  3 12:15 /usr/bin/javaws -> /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/javaws


Answer 2:

最后,一些工作!

西蒙Urbanek:可以请你穿上rJava网站/ CRAN这些说明安装说明......? 这是第一次,我一直沿着这兔子洞,我相信我不是唯一的一个。

JAVA_LD_LIBRARY_PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/server JAVA_LIBS='-L/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/server -ljvm' JAVA_CPPFLAGS='-I/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include/darwin' R CMD javareconf
Java interpreter : /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/bin/java
Java version     : 1.8.0_77
Java home path   : /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
Java compiler    : /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/javac
Java headers gen.: /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/javah
Java archive tool: /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/jar
System Java on OS X

trying to compile and link a JNI program
detected JNI cpp flags    : -I/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include/darwin
detected JNI linker flags : -L/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/server -ljvm
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/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.8.0_77.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_77.jdk/Contents/Home
Java library path: /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/server
JNI cpp flags    : -I/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include/darwin
JNI linker flags : -L/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/lib/server -ljvm
Updating Java configuration in /Library/Frameworks/R.framework/Resources
override rw-r--r--  root/admin for /Library/Frameworks/R.framework/Resources/etc/Makeconf? (y/n [n]) y
override rw-r--r--  root/admin for /Library/Frameworks/R.framework/Resources/etc/ldpaths? (y/n [n]) y
Done.

R CMD INSTALL rJava_0.9-9.tar.gz


文章来源: how to get rJava 0.9-3 to work on OS X 10.7.4 with Oracle Java 1.7?
标签: java macos r rjava