Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
258 views
in Technique[技术] by (71.8m points)

java - How does one configure rJava on OSX to select the right JVM -- .jinit() failing

I installed rJava by calling install.packages("rJava") -- no problems seen

However when I call:

library(rJava)
.jinit() 

I get:

JavaVM: requested Java version ((null)) not available. Using Java at "" instead.
JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
Error in .jinit() : JNI_GetCreatedJavaVMs returned -1

I'm running OSX:

Darwin MBP-2 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep  1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64

I have the following Sun JDK's installed:

$ ls /Library/Java/JavaVirtualMachines/
jdk1.7.0_79.jdk jdk1.8.0_65.jdk

Which Java is on my PATH:

$ which java
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home//bin/Java

I also have JavaHome defined as:

$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The answer at https://stackoverflow.com/a/36045290/4351357 helped resolve this issue for me on MacOS Sierra Version 10.12. In particular, it provided the code in command 1, below.

The three Terminal commands I used are:

  1. sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
  2. sudo R CMD javareconf
  3. install.packages("rJava",type='source')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...