After upgrading from Ubuntu 16 to 18.4, I am not able to install the rJava package in R.
I read other posts like this, but I didn't solve my issue.
if I run install.packages("rJava")
on R, Results is this:
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/home/salvatore/R/x86_64-pc-linux-gnu-library/3.5/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/salvatore/R/x86_64-pc-linux-gnu-library/3.5/rJava’
when I run sudo R CMD javareconf
:
Java interpreter : /usr/lib/jvm/java-8-oracle/jre/bin/java
Java version : 1.8.0_181
Java home path : /usr/lib/jvm/java-8-oracle
Java compiler : /usr/lib/jvm/java-8-oracle/bin/javac
Java headers gen.: /usr/lib/jvm/java-8-oracle/bin/javah
Java archive tool: /usr/lib/jvm/java-8-oracle/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/lib/jvm/java-8-oracle/include -I/usr/lib/jvm/java-8-oracle/include/linux -fpic -g -O2 -fdebug-prefix-map=/build/r-base-oNcpyf/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server -ljvm -L/usr/lib/R/lib -lR
JAVA_HOME : /usr/lib/jvm/java-8-oracle
Java library path: $(JAVA_HOME)/jre/lib/amd64/server
JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
Updating Java configuration in /usr/lib/R
Done.
Any help would be welcome.
On my clean installation of Ubuntu 18.04 LTS I did the following
(so I have R 3.4 from official repository).
Then in
R
or in RStudio 1.1.456 session:and it ended with
Note: I'm using default OpenJDK 11 from Bionic repository -
In my case, I also had to use:
sudo R CMD javareconf
, to make it work.Running Ubuntu 18.04 64-bit, R 3.60, and RStudio 1.2.1335.
In my case, I had to do the following:
(Temporarily) disable Oracle Java 8 by renaming jdk.csh and jdk.sh to jdk.csh.old and jdk.sh.old (in etc/profile.d).
Install java-11-openjdk.
Add JAVA_HOME="/usr/lib/jvm/java-11-openjdk" to /etc/environment.
Run "sudo update-alternatives --config java" and select "/usr/lib/jvm/java-11-openjdk-amd64.bin/java".
Run "sudo R CMD javareconf".
Logout/login.
Open RStudio and install rJava.
rJava then installed with no errors.
For me, I create a bash file using some of code of the previous answers. This is the bash file: