title: R: package or namespace load failed for ‘rJava’
body: <p>I have RStudio 1.1.419 running on a Mac OS El Capitan. I am trying to load the xlsx library. One of the dependencies is the rJava package. When I submit library(xlsx), I get the following error.</p>
  
  <blockquote>
  <pre><code>Loading required package: 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 
  
  Error: package ‘rJava’ could not be loaded
  </code></pre>
  </blockquote>
  
  <p>I found this thread: <a href="https://stackoverflow.com/questions/27661325/unable-to-load-rjava-on-r/30073113#30073113">Unable to load rJava on R</a></p>
  
  <p>Based on that, I reinstalled Java and used Sys.setenv(JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java") to update the path. I am still getting the error.</p>