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 :
- Create the java and the cc files (cf. link above) in the same repertory.
- 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 }
- Go the repertory and compile the java class :
$ javac Main.java
.
- 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
)
- Export the lib path
$ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LIBPATH}
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 ofjni_md.h
in the same folder ofjni.h
c. Compile as follows :
$ g++ -Wall main.cc -I/PATH_TO_jni.h -L${LIBPATH} -ljvm
- 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
Pdfbox:Pdpagecontentstream's Append Mode Misbehaving
How to Install "Android Support Library" to Deploy a Gluon Mobile Application to Android
Aes Gcm Implementation with Authentication Tag in Java
How to Install Rjava in R 3.0 in Ubuntu 13.04
How to Run an R Program from Java
Java Object Analogue to R Data.Frame
Libjvm.So: Cannot Open Shared Object File: No Such File or Directory
Loading Data Bigger Than the Memory Size in H2O
Aes/Cbc/Pkcs5Padding Encrypt in Java Decrypt in Ruby
Why Does My Compare Method Throw Exception -- Comparison Method Violates Its General Contract!
Trivial: Get Confirmation of Email Sent in Android
Creating an Arraylist of Objects