开发者

Java can't seem to find my native libraries

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 "n开发者_运维问答o 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!


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜