Unable to install rJava in R 3.0 in Ubuntu 13.04

2019-01-10 13:48发布

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.

3条回答
相关推荐>>
2楼-- · 2019-01-10 14:26

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/ 
查看更多
你好瞎i
3楼-- · 2019-01-10 14:42

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.

查看更多
孤傲高冷的网名
4楼-- · 2019-01-10 14:43

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.

查看更多
登录 后发表回答