0

I installed the rJava package but it's showing the following issue while using the library

library("rJava") 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

  • Share your machine's sessionInfo() ! – amrrs Nov 06 '17 at 09:15
  • for ubuntu , run it via apt-get - "sudo apt-get install r-cran-rjava". – niths4u Nov 06 '17 at 09:37
  • It macOS Sierra Versio 10.12.6 (16G29) – Vipul Agrawal Nov 06 '17 at 11:55
  • 1
    You aren't alone, this is a common problem on macOS. You need to run the following in R: `dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server/libjvm.dylib')`. You'll have to actually go to `/Library/Java/JavaVirtualMachines` to determine what your exact version of the `.jdk` is, but that always works for me. You can put this in your `.Rprofile` to be loaded at startup if you use `rJava` often. Edit: to give credit where it is due, this is the original source: http://charlotte-ngs.github.io/2016/01/MacOsXrJavaProblem.html – Davis Vaughan Nov 06 '17 at 15:17
  • Getting this error or running the follwing command in R: dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server/libjvm.dylib') Error in dyn.load("/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Hosme/jre/lib/server/libjvm.dylib") : unable to load shared object .Further, jdk are : 1.6.0.jdk, jdk-9.0.1.jdk, jdk1.8.0_151.jdk '/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server/libjvm.dylib': dlopen(/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server/libjvm.dylib, 6): image not found – Vipul Agrawal Nov 07 '17 at 04:44
  • Take a look here: http://www.owsiak.org/r-3-4-rjava-macos-and-even-more-mess/ – Oo.oO Nov 08 '17 at 06:46

0 Answers0