本文介绍了如何在OSX上配置rJava以选择正确的JVM - .jinit()失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过调用install.packages(rJava)来安装rJava - 没有遇到任何问题
I installed rJava by calling install.packages("rJava") -- no problems seen
但是当我打电话时:
library(rJava)
.jinit()
我得到:
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
我正在运行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
我安装了以下Sun JDK:
I have the following Sun JDK's installed:
$ ls /Library/Java/JavaVirtualMachines/
jdk1.7.0_79.jdk jdk1.8.0_65.jdk
我的路径中有哪个Java:
Which Java is on my PATH:
$ which java
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home//bin/Java
我还将JavaHome定义为:
I also have JavaHome defined as:
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/
推荐答案
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:
-
sudo ln -s $(/ usr / libexec / java_home)/jre/lib/server/libjvm.dylib / usr / local / lib
-
sudo R CMD javareconf
-
install.packages( rJava,type ='source')
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
sudo R CMD javareconf
install.packages("rJava",type='source')
这篇关于如何在OSX上配置rJava以选择正确的JVM - .jinit()失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!