tags:

views:

64

answers:

2

Hi,

I am trying to run my program from my jar, called PViz.jar. The jar is sitting in a directory with all of its dependent jars and the .so files that they depend on. I am using Mac OS X. When I run this:

java -cp PViz.jar pviz.PVizStart

Then I get an UnsatisfiedLinkError saying "no jogl in java.library.path". This is reasonable, i'm using jogl.jar which makes use of the native library libjogl.so.

So I run this:

java -Djava.library.path=. -cp PViz.jar pviz.PVizStart

and I get the same error. But libjogl.so is in the current directory! I figured maybe I needed to give the whole path, so I tried this:

java -Djava.library.path=/bla/bla/bla/libjogl.so -cp PViz.jar pviz.PVizStart

and it still gives me the same UnsatisifedLinkError. Argh!

A: 

Try loading the lib in a static initializer in one of the main classes of your app.

Example (Copied + renamed from one of my projects):

public class MainClass {
    static {
        System.loadLibrary( "Your_native_lib_file_name" ); // Note: do not include the file extension!
    }
}

The native lib should be in the same directory as your jar.

Andy
I get the exact same error. I tried it doing this with -Djava.library.path-. and -Djava.library.path=/exact/path/to/dir/ and I still get the stupid UnsatisfiedLinkError.
evilfred
I used System.loadLibrary("jogl"); where libjogl.so is in the same directory as the jar.
evilfred
Are the native libs sitting next to their respective jar files in your directories?
Andy
Use System.loadLibrary("libjogl");
Andy
Yes they are Andy. I'll try that I guess.
evilfred
same error. this time it complains about libjogl instead of jogl. same diff :(
evilfred
Did you ever get it working?
Andy
+2  A: 

Here is a step by step explanation on how to setup jogl on different operating systems, OS X included.

zellus
hmmm... well it already works fine from eclipse...
evilfred
eclipse does a fair amount of voodoo.
zellus