Having problems with rJava on macOS

387 Views Asked by At

So I tried to install the package bartMachine in R-studio, which installs the dependency rJava... however, I'm having difficulties getting rJava to work on my macOS.

This question has been asked multiple times but none of the solutions seem to work for me.

Here's the error I get in R-Studio when I try to load the rJava library:

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.5/Resources/library/rJava/libs/rJava.so':

dlopen(/Library/Frameworks/R.framework/Versions/3.5/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.5/Resources/library/rJava/libs/rJava.so
      Reason: image not found

I've tried reinstalling the JDE, JDK etc but nothing seems to work... when I run java -version in the terminal it shows me this:

java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

I'm using macOS Mojave, version: 10.14.3... and R-Studio version: 1.1.456.

Any suggestions as to how I's fix this problem?

0

There are 0 best solutions below