Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libjvm.so: cannot open shared object file: No such file or directory

Trying to install the rJava package on R, on my 14.10 ubuntu, using this code

if (!require(rJava)) install.packages('rJava') 

got few errors related to java including jni problems, after reinstalling the jdk, and tried to run the same code again, got that error

Error : .onLoad failed in loadNamespace() for 'rJava', details:   call: dyn.load(file, DLLpath = DLLpath, ...)   error: unable to load shared object '/usr/local/lib/R/site-library/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 ‘/usr/local/lib/R/site-library/rJava’ Warning in install.packages :   installation of package ‘rJava’ had non-zero exit status  The downloaded source packages are in     ‘/tmp/RtmpfFjrp0/downloaded_packages’ Warning message: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :   there is no package called ‘rJava’ 

looked for solutions, to find just about everyone suggesting (for x64) to execute those commands

export LD_LIBRARY_PATH=/usr/lib/jvm/java-8-oracle/lib/amd64:/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server sudo R CMD javareconf  

but that didn't work, is there anything else I can do? I will provide any needed details

like image 800
tan Avatar asked Feb 11 '15 18:02

tan


People also ask

Why libjvm cannot open shared object file on Unix box?

Adding the answer if we have two R version running on Unix Box. Issue: libjvm.so: cannot open shared object file: No such file or directory Caused due to: Updated the version of java from java-1.8.0-openjdk-1.8.0.262.b10-1.el7_9.x86_64 to java-1.8.0-openjdk-1.8.0.272.b10-1.el7_9.x86_64

Why “Java-version” quits with “error while loading shared libraries”?

“java -version” quits with the error message “error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory” when trying to start the JVM. The problem is there if it is run under a normal user or if it is run under the root user

What is /bin/Kinit error while loading shared libraries?

Error: /bin/kinit: error while loading shared libraries: libjvm.so: cannot open shared object file: No such file or directory. From the stack trace of the script, we identified that the environment variable LD_PRELOAD was loading from the Integration service.

Where can I find the libjvm file?

Find the libjvm.so file which is usually in the usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server path depending on which jre you're using. Check in $JAVA_HOME environment. Sorry, something went wrong.


2 Answers

To solve this,

  1. Run

    sudo R CMD javareconf

  2. Add the following to to /etc/environment. This will then be set every time your machine restarts.

    LD_LIBRARY_PATH=/usr/lib/jvm/default-java/jre/lib/amd64/server/

    (change to your path)

  3. Run the following:

    source /etc/environment

  4. rstudio server restart
like image 193
aGentlemanAndAScholar Avatar answered Sep 27 '22 22:09

aGentlemanAndAScholar


I was getting the same error when I was trying to load rJava in RStudio. The following solution worked for me

1) sudo rstudio-server stop 2) export LD_LIBRARY_PATH=/usr/lib/jvm/jre/lib/amd64:/usr/lib/jvm/jre/lib/amd64/default 3) sudo rstudio-server start 

After performing the above steps, I was able to run the following successfuly in RStudio

> library("DBI") > library("rJava") > library("RJDBC") 
like image 40
minhas23 Avatar answered Sep 27 '22 22:09

minhas23