Search code examples
javamacosrjava

Using Rjava on Mac. Relevant library libjvm.dylib does not exist


I cannot use R with Java on the Mac. There is a wealth of information on the web, including on Stack Overflow (e.g. rJava load error in RStudio/R after "upgrading" to OSX Yosemite), but none of this helps me. The standard advice is to find the file libjvm.dylib, and to set up a link to this as follows;

sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

The problem is that I do not have the file libjvm.dylib anywhere on my system, despite repeatedly downloading the latest version of Java from Oracle.

My Java home is as follows; /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home.

The Java version is; java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode).

The tree structure of my java home (directories only) is;

enter image description here

It looks completely different from the tree structure which I'm supposed to have, e.g. there is no 'jre' folder.

Thanks in advance.


Solution

  • You don't have to make symbolic links etc. You simply need to properly configure Java and R to get them running smooth.

    Take a look here: R, Java, rJava and macOS adventures

    Recently, I have updated this entry for more recent R - R 3.4. Take a look here: R 3.4, rJava, macOS and even more mess ;)

    Maybe this time it will help ;)