Unable to install rJava in R 3.0 in Ubuntu 13.04

匿名 (未验证) 提交于 2019-12-03 01:08:02

问题:

I am not able to call rJava package in R 3.0. I got the following message

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

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.

回答1:

I ran into the exact same issue. My solution was to install the openjdk-7-* via

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").

While perhaps not the most elegant solution it appears to have solved my problems with getting rJava to work.



回答2:

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:

$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/  


回答3:

Installing rJava from the distribution packages as proposed in this askUbuntu answer also works:

sudo apt-get install r-cran-rjava 

NOTE: tried from a Debian system.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!