Loading JNI lib on OSX?

Posted by Clinton on Stack Overflow See other posts from Stack Overflow or by Clinton
Published on 2010-03-31T04:52:55Z Indexed on 2010/03/31 7:53 UTC
Read the original article Hit count: 658

Filed under:
|
|
|

Background

So I am attempting to load a jnilib (specifically JOGL) into java on OSX at runtime. I have been following along the relevant stackoverflow questions:

The end goal for me is to package platform specific JOGL files into a jar and unzip them into a temp directory and load them at start-up. I worked my problem back to simply attempting to load JOGL using hard-coded paths:

    File f = new File("/var/folders/+n/+nfb8NHsHiSpEh6AHMCyvE+++TI/-Tmp-/libjogl.jnilib");
    System.load(f.toString());
    f = new File ("/var/folders/+n/+nfb8NHsHiSpEh6AHMCyvE+++TI/-Tmp-/libjogl_awt.jnilib");
    System.load(f.toString());

I get the following exception when attempting to use the JOGL API:

    Exception in thread "main" java.lang.UnsatisfiedLinkError: no jogl in java.library.path

But when I specify java.library.path by adding the following JVM option:

    -Djava.library.path="/var/folders/+n/+nfb8NHsHiSpEh6AHMCyvE+++TI/-Tmp-/" 

Everything works fine.


Question

Is it possible use System.load (or some other variant) on OSX as a replacement for -Djava.library.path that is invoked at runtime?

© Stack Overflow or respective owner

Related posts about java

Related posts about jni