Libjvm.So: Cannot Open Shared Object File: No Such File or Directory

Trouble in Setting Java Environment Path on Ubuntu (libjvm.so: cannot open shared object file: No such file or directory)

Found the solution!

Ubuntu by default ignore the command "RD_LIBRARY_PATH" therefore I need to add those codes in ".bashrc" instead of "/etc/environment" or .profile.

it now work perfectly fine!

error while loading shared libraries: libjvm.so:

I found a very good example, one of the best on the web I guess, because the author wrote down the paths of each file he uses : Tutorial

I still had a library problem so here is how I managed to get all working :

  1. Create the java and the cc files (cf. link above) in the same repertory.
  2. Edit the following line in main.cc with the path of your Java class :

{ const_cast<char*>("-Djava.class.path=PATH_TO_JAVA_CLASS"), NULL }


  1. Go the repertory and compile the java class :

$ javac Main.java.


  1. Look for the file libjvm.so on your computer. Once you have
    found it, edit the lib path as follows :

$ LIBPATH=PATH_TO_LIBJVM.SO

(for me it was in /usr/lib/jvm/java-1.7.0-openjdk-1.7.0/jre/lib/amd64/server
)


  1. Export the lib path

$ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LIBPATH}


  1. Now you just have to compile the main.cc file. I had a problem because jni.h was not found:

    a. Find jni.h (for me /usr/lib/jvm/java-1.7.0-openjdk-1.7.0/include/)

    b. If you have a problem with jni_md.h, create a symbolic link of jni_md.h in the same folder of jni.h

    c. Compile as follows :

$ g++ -Wall main.cc -I/PATH_TO_jni.h -L${LIBPATH} -ljvm


  1. Should be good :)

./a.out

Hello, world!

Hello, Java!

Linux - Error loading rJava in Rstudio: libjvm.so: missing?

You may want to locate the library, you can use the whereis command or look into standard path which are :

/usr/lib/jvm/java-7-oracle/lib/amd64
/usr/lib/jvm/java-7-oracle/jre/lib/amd64/server

Once it's located, copy its folder's path.

Then add it to the LD_LIBRARY_PATH environment variable located in ~/.profile (create the file if needed).

export LD_LIBRARY_PATH=/usr/lib/jvm/java-7-oracle/lib/amd64:/usr/lib/jvm/java-7-oracle/jre/lib/amd64/server

If you already have a LD_LIBRARY_PATH set you may want to keep it, so echo $LD_LIBRARY_PATH and add its content into the ~/.profile file.

You can reboot to reload the .profile, or you can just source ~/.profile form a terminal.

To conclude just sudo R CMD javareconf.

Pyjnius looking for libjvm.so in wrong folder - Ubuntu 16.04

I have managed to resolve this issue. As far as I can tell, I had set the JAVA_HOME to point at the correct installation of Java but needed to log out and back in for the changes to take effect.



Related Topics



Leave a reply



Submit