Installed rJava, Installed Java 8 update. Still ca

2019-08-26 19:28发布

Bear in mind that I am computer illiterate and new to R. I have installed the rJava package in R studio version 1.0.143 and installed Java 8 (using MacOS Sierra). When I try to load the rJava package:

library(rJava)

I get the following error

Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
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 
 '/Users/cormac/Library/R/3.4/library/rJava/libs/rJava.so':
 dlopen(/Users/cormac/Library/R/3.4/library/rJava/libs/rJava.so, 6): 
 Library not loaded: @rpath/libjvm.dylib
 Referenced from: 
/Users/cormac/Library/R/3.4/library/rJava/libs/rJava.so
Reason: image not found
In addition: Warning messages:
1: package ‘rJava’ was built under R version 3.4.2 
2: running command '/usr/libexec/java_home' had status 1 

Could somebody help me to interpret this error message? There is probably a very simple solution, but I am completely lost. Thank you!!

标签: r rjava
1条回答
混吃等死
2楼-- · 2019-08-26 20:13

As noted in Unable to load rJava in RStudio, there is a very specific sequence of steps that must be taken to get rJava to work on a Macbook, as documented in rJava Issues #86.

  1. Download and install Java from Oracle
  2. Uninstall any previously installed version of rJava
  3. Add JAVA_HOME to your .bashrc
  4. Close & restart terminal, R and RStudio sessions so they pick up the updated JAVA_HOME
  5. Use install.packages() to install rJava

See the URL link above for additional details on each step.

查看更多
登录 后发表回答