2

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.

1

In my case, I also had to use: sudo R CMD javareconf, to make it work.

1

On my clean installation of Ubuntu 18.04 LTS I did the following

sudo apt-get install r-base-dev default-jdk

(so I have R 3.4 from official repository).

Then in R or in RStudio 1.1.456 session:

install.packages('rJava')

and it ended with

* DONE (rJava)

Note: I'm using default OpenJDK 11 from Bionic repository -

$ update-java-alternatives -l
java-1.11.0-openjdk-amd64      1101      /usr/lib/jvm/java-1.11.0-openjdk-amd64
  • I'm done. On R it work fine, the issues occour on Rstudio. – Salvo Comunque Aug 27 '18 at 16:29
  • I can't reproduce your issue using R 3.4. Why do you use R 3.5? – N0rbert Aug 27 '18 at 16:34
  • 1
    Perfect, I removed R 3.5 and installed R3.4, after installing R studio, all thing works fine. Thank you so mutch for your answer. – Salvo Comunque Aug 27 '18 at 17:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.