Java JNI: Unsatisfied Link Error in Library Path

I’m currently playing around with Java Native Interfaces(JNI) and I must say its been too long since I programmed in Java. Its good to be back! Anyway, lets hop to the main topic…

I was following the tutorial from Sun in creating my first JNI and calling my compiled C++ library, I was stuck in the last part where this error popped out whenever I tried to invoke

java HelloWorld

the error was…

java.lang.UnsatisfiedLinkError: no HelloWorld in java.library.path
          at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
          at java.lang.Runtime.loadLibrary0(Runtime.java:823)
          at java.lang.System.loadLibrary(System.java:1030)
          at HelloWorld.<clinit>(HelloWorld.java:<line number>)
Could not find the main class: HelloWorld. Program will exit.

one way of fixing this is to include the current location of your newly compiled shared library (ex. HelloWorld.so). I’m using Ubuntu linux,so to include the current folder where your “.so” file is located, invoke…

LD_LIBRARY_PATH=`pwd`
export LD_LIBRARY_PATH

or you can also do …
Continue Reading