Skip to content

Why am I getting this UnsatisfiedLinkError with native code?

I have a library called and a program with this content:

class HelloWorld {
     private native void print();
     public static void main(String[] args) {
         new HelloWorld().print();
     static {

Now when I try to run I get this error:

$ /usr/java1.4/bin/java HelloWorld
Exception in thread "main"
java.lang.UnsatisfiedLinkError: no HelloWorld in java.library.path
        at java.lang.ClassLoader.loadLibrary(
        at java.lang.Runtime.loadLibrary0(
        at java.lang.System.loadLibrary(
        at HelloWorld.<clinit>(

Any tips?



@mmyers Thank you for responding. We found out that all we had to do was change System.loadLibrary to System.load and pass the full path + filename as argument, worked like a charm.

Even before doing so, we tried using the “-D” parameter and setting LD_LIBRARY_PATH but we weren’t successful.

Go figure! 🙂

Thanks again, Karen

4 People found this is helpful