install rJava - One or more JNI types differ from

2019-05-09 11:04发布

I am trying to get a working R environnement on my mac. I just updated to Mac OS 10.11.1.

From rStudio, install.packages("rJava") leads to this error:

checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : '-I/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/../include/darwin'
java libs   : '-L/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/lib/server -ljvm'
checking whether Java run-time works... yes
checking whether -Xrs is supported... yes
checking whether JNI programs can be compiled... yes
checking JNI data types... 
configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
ERROR: configuration failed for package ‘rJava’
* removing ‘/usr/local/lib/R/3.2/site-library/rJava’

The output of R CMD javareconf is:

Java interpreter : /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/bin/java
Java version     : 1.8.0_66
Java home path   : /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home
Java compiler    : /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/bin/javac
Java headers gen.: /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/bin/javah
Java archive tool: /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/bin/jar
System Java on OS X

trying to compile and link a JNI program 
detected JNI cpp flags    : -I/System/Library/Frameworks/JavaVM.framework/Headers
detected JNI linker flags : -framework JavaVM
clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include  -I/usr/local/include   -fPIC  -g -O2  -c conftest.c -o conftest.o
conftest.c:4:5: warning: 'JNI_CreateJavaVM' is deprecated [-Wdeprecated-declarations]
JNI_CreateJavaVM(0, 0, 0);
^
/System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1937:1: note:    'JNI_CreateJavaVM' has been explicitly marked deprecated here
JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *args);
^
1 warning generated.
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -        L/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/lib -    L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/usr/local/lib -o conftest.so conftest.o -framework JavaVM -F/usr/local/Cellar/r/3.2.2_1/R.framework/.. -framework R -lintl -Wl,-framework -Wl,CoreFoundation


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home
Java library path: 
JNI cpp flags    : -I/System/Library/Frameworks/JavaVM.framework/Headers
JNI linker flags : -framework JavaVM
Updating Java configuration in /usr/local/Cellar/r/3.2.2_1/R.framework/Resources

I have no clue. Any idea to fix this?

Thanks

1条回答
【Aperson】
2楼-- · 2019-05-09 11:37

I had exactly the same problem, and finally resolved, via a solution I found here.

The new Mac OS X (10.11, El Capitan) has trouble with env variables.


The newest dev flavor of rJava manages to handle things correctly. Here is what I did to resolve it:

  1. Download version 0.9-8 (rJava_0.9-8.tar.gz) from here
  2. Install it from the downloaded source:

    $ R CMD INSTALL ~/Downloads/rJava_0.9-8.tar.gz

(Or wherever you put it)

That's all it took!

查看更多
登录 后发表回答