Unable to install rJava in R 3.0 in Ubuntu 13.04

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.

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.

Unable to install rJava in R 3.0 in Ubuntu 13.04, 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� Simply start by installing r-cran-rjava from terminal $ sudo apt-get install r-cran-rjava Then from R, simply run this. install.packages('rJava')

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/ 

Unable to install rJava in R 3.0 in Ubuntu 13.04, I am not able to call rJava package in R 3.0. I got the following messageError: package 'rJava' was built before R 3.0.0: please re-install itI am� Installing the rJava package on Ubuntu is not quite as simple as most other R packages. Some quick notes on how to do it. Install the Java Runtime Environment (JRE). sudo apt-get install -y default-jre

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.

[R-sig-Debian] r-cran-rjava (ubuntu 13.04 ?) -- missing dependencies?, [R-sig-Debian] r-cran-rjava (ubuntu 13.04 ?) Previous message: [R-sig-Debian] Cannot install XML package with R 3.0 and Ubuntu 12.04� Hi! My name is Baobao Zhang and I'm a PhD student at Yale. I studied with Jay actually. It's a small world. I trying to use the package on an Ubuntu E3 AWS server and I'm having problems with rJava. The problem is that when I try to init

I was also facing same error which was on RHEL8.1 & i resolved it as follows:

yum --enablerepo=* install java-1.8* 

later i ran same command which was giving me error logs of R server.

R CMD javareconf

which turns into following output.

無法在Ubuntu 13.04中的R 3.0中安裝rJava, 問題描述. 我無法在 R 3.0 中調用 rJava 程序包。我收到以下消息. Error: package ' rJava' was built before R 3.0.0: please re-install it. installing rJava. Dear R People: I am trying to install rJava on an Ubuntu 13.04 64 bit system. But the Java part is causing me fits. Here is the code: >

无法在Ubuntu 13.04中的R 3.0中安装rJava, Error: package 'rJava' was built before R 3.0.0: please re-install it make: *** [ conftest.o] Error 1 Unable to compile a JNI program Java library� Make sure R is configured with full Java support (including JDK). Run R CMD javareconf as root to add Java support to R. If you don't have root privileges, run R CMD javareconf -e to set all Java-related variables and then install rJava.

java — No se puede instalar rJava en R 3.0 en Ubuntu 13.04, No puedo llamar al paquete rJava en R 3.0. Me lleg� el siguiente mensajeError: package 'rJava' was built before R 3.0.0: please re-install it Recibo un error al� I'm trying to compile gplates from source, since there isn't currently a .deb file for 20.04 fossa yet, but it requires using qt4 and subsequently qwt for

java — �Por qu� rJava no funciona en Ubuntu 14.04 con OpenJDK 7?, Sudo apt-get install openjdk-7-jdk Sudo apt-get install r-cran-rjava error: unable to load shared object '/usr/lib/R/site-library/rJava/libs/rJava.so': libjvm.so: cannot open Estoy en Ubuntu 14.04 64 bit y estoy usando la versi�n R 3.1.0 ( 10/04/2014) - "Spring Dance" No se puede instalar rJava en R 3.0 en Ubuntu 13.04.

Comments
  • Thank you. It worked. I have tried installing java yesterday.I also tried Oracle Java, but didn't work. Not sure I was installing JRE or reboot did the trick.
  • no luck for me: first two steps run without error, then on install.packages I get: error: unable to load shared object '/home/cboettig/R/x86_64-pc-linux-gnu-library/3.0/rJava/libs/rJava.so': libjvm.so: cannot open shared object file: No such file or directory. Any ideas?
  • I ran into the same problem - didn't work. Finally found that after installing Java 1.7, I had to tell Ubuntu to use that as default - see here - using update-java-alternatives -l to get list of java versions installed and sudo update-java-alternatives -s java-1.7.0-openjdk-i386 to default to 1.7. After this, sudo R CMD javareconf ran without error and I was able to install.packages("rJava")
  • For those looking at this more recently try sudo apt-get install openjdk-8-*
  • Does work for Ubuntu 18.04 (e. g. to install the R packages xlsx or ELT)