title: Loading JNI lib on Mac OS X?
body: <p><strong>Background</strong></p>
  
  <p>So I am attempting to load a jnilib (specifically <a href="http://en.wikipedia.org/wiki/Java_OpenGL" rel="nofollow noreferrer">JOGL</a>) into Java on Mac OS X at runtime. I have been following along the relevant Stack Overflow questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/1962718/maven-and-the-jogl-library">Maven and the JOGL Library</a></li>
  <li><a href="https://stackoverflow.com/questions/2535700/loading-dll-in-java-eclipse-jni">Loading DLL in Java - Eclipse - JNI</a></li>
  <li><a href="https://stackoverflow.com/questions/2535700/loading-dll-in-java-eclipse-jni">How to make a jar file that include all jar files</a></li>
  </ul>
  
  <p>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:</p>
  
  <pre><code>    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());
  </code></pre>
  
  <p>I get the following exception when attempting to use the JOGL API:</p>
  
  <pre><code>    Exception in thread "main" java.lang.UnsatisfiedLinkError: no jogl in java.library.path
  </code></pre>
  
  <p>But when I specify <code>java.library.path</code> by adding the following JVM option:</p>
  
  <pre><code>    -Djava.library.path="/var/folders/+n/+nfb8NHsHiSpEh6AHMCyvE+++TI/-Tmp-/" 
  </code></pre>
  
  <p>Everything works fine.</p>
  
  <hr>
  
  <p><strong>Question</strong></p>
  
  <p>Is it possible use <code>System.load</code> (or some other variant) on Mac OS X as a replacement for -Djava.library.path that is invoked at runtime?</p>