s-u / rJava

R to Java interface
https://RForge.net/rJava
235 stars 77 forks source link

Issue in loading rJava in Mac #185

Closed nehakash closed 5 years ago

nehakash commented 5 years ago

I am trying to install rJava so that I can use qdap and Rweka but I am getting error. Installed JDK and reconfigured R but still getting this error. Please help

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.6/Resources/library/rJava/libs/rJava.so': dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so Reason: image not found

PeterNSteinmetz commented 5 years ago

Just was struggling with a similar issue. It was happening because of a mismatch between the jvm path listed in the DYLD_FALLBACK_LIBRARY_PATH variable and that used to compile the version of rJava being used. Perhaps check which variables are listed in Sys.getenv() on the R command line?

iwiaCorp commented 5 years ago

it is all about version JDK installed in your Mac OS and rJava version. My java version Mac is 11.0.3 and rJava is pointer to 11.0.1. I have to edit the file rJava.so and set 11.0.3. part of the code: /Library/Java/JavaVirtualMachines/jdk-11.0.3.jdk/Contents/Home/lib/server/libjvm.dylib /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libR.dylib

Other solutions is to download java JDK 11.0.1 and I think it is the better solutions.

s-u commented 5 years ago

Please follow the R instructions - you have to configure R for whichever Java version you are using via R CMD javareconf.