无法在 Ubuntu 13.04 的 R 3.0 中安装 rJava
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16438073/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to install rJava in R 3.0 in Ubuntu 13.04
提问by vinux
I am not able to call rJava
package in R 3.0
. I got the following message
我无法rJava
在R 3.0
. 我收到以下消息
Error: package ‘rJava' was built before R 3.0.0: please re-install it
I am getting error when I tried to re-install rJava
package. I have provided the output of R CMD javareconf
当我尝试重新安装rJava
软件包时出现错误。我提供了输出R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.7.0_21
Java home path : /usr/lib/jvm/java-7-openjdk-i386/jre
Java compiler : /usr/lib/jvm/java-7-openjdk-i386/jre/../bin/javac
Java headers gen.: /usr/lib/jvm/java-7-openjdk-i386/jre/../bin/javah
Java archive tool: /usr/lib/jvm/java-7-openjdk-i386/jre/../bin/jar
trying to compile and link a JNI progam
detected JNI cpp flags :
detected JNI linker flags :
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -O2 -pipe -g -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: No such file or directory
compilation terminated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /usr/lib/R
Done.
I am using Ubuntu 13.04. I also tried apt-get install r-cran-rjava
which is not helping to solve the issue. Regarding jni.h there were some solution here.But, not sure how can I use the solution here.
我正在使用 Ubuntu 13.04。我也试过apt-get install r-cran-rjava
这无助于解决问题。关于 jni.h 这里有一些解决方案。但是,不确定如何使用这里的解决方案。
采纳答案by Peter
I ran into the exact same issue. My solution was to install the openjdk-7-* via
我遇到了完全相同的问题。我的解决方案是通过以下方式安装 openjdk-7-*
sudo apt-get install openjdk-7-*
Followed that with
随之而来的是
sudo R CMD javareconf
and I was then able to install rJava in R via install.packages("rJava")
.
然后我就可以通过 .rJava 在 R 中安装 rJava install.packages("rJava")
。
While perhaps not the most elegant solution it appears to have solved my problems with getting rJava to work.
虽然可能不是最优雅的解决方案,但它似乎解决了我让 rJava 工作的问题。
回答by kahlo
For those getting the error:
对于那些收到错误的人:
error: unable to load shared object '/some/dir/rJava/libs/rJava.so': libjvm.so:
cannot open shared object file: No such file or directory
I solved the error locating the library in the system and linking them to /usr/lib
:
我解决了在系统中定位库并将它们链接到的错误/usr/lib
:
$sudo updatedb
$locate libjvm.so
/usr/lib/debug/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so
/usr/lib/debug/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/zero/libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/jamvm/libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/zero/libjvm.so
$sudo ln -s /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so /usr/lib/
回答by atfornes
Installing rJava from the distribution packages as proposed in this askUbuntu answeralso works:
按照此 askUbuntu 答案中的建议从分发包安装 rJava也有效:
sudo apt-get install r-cran-rjava
NOTE: tried from a Debian system.
注意:在 Debian 系统中尝试过。
回答by Santosh Garole
I was also facing same error which was on RHEL8.1 & i resolved it as follows:
我也遇到了 RHEL8.1 上的相同错误,我按如下方式解决了它:
yum --enablerepo=* install java-1.8*
later i ran same command which was giving me error logs of R server.
后来我运行了相同的命令,它给了我 R 服务器的错误日志。
R CMD javareconf
which turns into following output.
变成以下输出。