title: How to load rJava into RStudio?
body: <p>Although I'm running the risk of duplicating questions, I have yet to find a solution to my configuration. </p>
  
  <p>I'm trying to load rJava into RStudio. </p>
  
  <p>I am using the latest Mac OS x, with a build of Rstudio that's only a couple of months old, and I've just installed JDK x64 12.0.1
  The version of rJava is 0.9-11</p>
  
  <p>On executing:</p>
  
  <pre><code>library(rJava)
  </code></pre>
  
  <p>I am confronted with the usual:</p>
  
  <p>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</p>
  
  <p>I've tried setting my Java home path to:</p>
  
  <pre><code>Sys.setenv(JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home')
  </code></pre>
  
  <p>But that doesn't make any difference. </p>
  
  <p>I've clearly missed the rJava instructions somewhere which lays out how to install the package on all computer setups. I'd appreciate some assistance.</p>
  
  <p><strong>EDIT #1</strong></p>
  
  <p>Following the link provided in the comments below, I managed to get the latest version of Java JDK running through rJava in RStudio. The document "R, Java, rJava and macOS adventures" isn't complete and doesn't work off the cuff. You'll probably end up hacking about to get it working. </p>
  
  <p>I needed rJava to run venneuler, unfortunately, this was not work using the latest Oracle JDK version 12:</p>
  
  <p><em>WARNING: Initial Java 12 release has broken JNI support and does NOT work. Use stable Java 11 (or watch for 12u if available).
  ERROR: Java exception occurred during rJava bootstrap - see stderr for Java stack trace.</em></p>
  
  <p>I'm going to try (wish me luck) to get two versions of Java on my machine and have RStudio recognise the right one. </p>
  
  <p><strong>Edit 2</strong></p>
  
  <p>Pure luck I think I have Java 11 working: 
  <a href="https://i.stack.imgur.com/hCtbL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hCtbL.png" alt="enter image description here"></a></p>