I continue to have trouble installing and loading rJava. I have R 3.4.1 ('Single Candle'); Java v 9 and mac OS 10.12.6.
I followed all of the steps listed here which included using Terminal to edit my ~/.profile to include:
export JAVA_HOME=$(/usr/libexec/java_home -v 9)
export PATH=$JAVA_HOME/bin:$PATH
And making other changes to connect R to the 'right' Java. When I run
sudo R CMD javareconf
however, I get an error message that says:
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.
And when I run
R CMD INSTALL rJava_0.9-8.tar.gz
Everything goes smoothly until I get an error that says:
checking whether JNI programs can be compiled… configure: error: Cannot compile a simple JNI program. See config.log for details.
Make sure you have Java Development Kit installed and correctly registered in R. If in doubt, re-run “R CMD javareconf” as root.
ERROR: configuration failed for package ‘rJava’
Michal from the site linked above kindly suggested to make sure that '/usr/libexec/java_home -v 9' "points" to JDK and not JRE. I am not sure how to do this. Also when I try something like:
echo $JAVA_HOME
I get:
/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
How do I know if this JDK or JRE?
Due to my error messages, I think I have a JNI problem, but I am not sure how to go about STARTING to deal with that issue. Any insight regarding what might have gone wrong using Michal's tutorial would be greatly appreciated!
P.S. My original issue was in R, trying to load library(rJava) and getting this error:
Error: package or namespace load failed for ‘rJava’: .onLoad failed in loadNamespace() for 'rJava', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so': dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: @rpath/libjvm.dylib Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so Reason: image not found