Wednesday, August 8, 2012 cannot open shared object file: No such file or directory

In my Ubuntu Linux, I was trying to call Java from C++ using JNI. Compiling progress was succeed but at runtime I saw an error on concole: cannot open shared object file: No such file or directory

Finding the right solution took five seconds but it was quite easy. I modified the LD_LIBRARY_PATH environment variable using export command in the Linux shell:

export LD_LIBRARY_PATH=/usr/lib/jvm/default-java/jre/lib/i386:/usr/lib/jvm/default-java/jre/lib/i386/client

The location of JDK is always changed because of updates but Ubuntu stores the links of current JVM in default-java directory. It is /usr/lib/jvm/default-java in my Linux. Two directories must be added to LD_LIBRARY_PATH. The first one is jre/lib/i386 and the second one is jre/lib/i386/client or jre/lib/i386/server in default-java directory. Use of export solves my problem.

Good luck!


  1. Thank you for your information. I get this error too in my Ubuntu

  2. Hello! It was such a pleasure to visit your blog and especially to read this post. Will you be so kind and provide an answer to my question. Have you ever practiced guest blogging?

  3. I love you man!!

  4. I solved this too.
    It works.