title: java.lang.UnsatisfiedLinkError on Linux
body: <p>I have a library that's been built on Linux and can be found here:</p>
  
  <pre><code>/test/lib/liblzo.so
  </code></pre>
  
  <p>I then have the following Java code:</p>
  
  <p>import org.junit.Test;</p>
  
  <pre><code>public class CompressionTest {
  
      @Test
      public void testCompression() throws Exception {
          System.out.println("java.library.path=" + System.getProperty("java.library.path"));
          try {
              System.loadLibrary("lzo");
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
  }
  </code></pre>
  
  <p>Running this produces the following exception:</p>
  
  <pre><code>CompressionTest &gt; testCompression FAILED
          java.lang.UnsatisfiedLinkError: no lzo in java.library.path
              at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1878)
              at java.lang.Runtime.loadLibrary0(Runtime.java:849)
              at java.lang.System.loadLibrary(System.java:1087)
              at CompressionTest.testCompression(CompressionTest.java:11)
  </code></pre>
  
  <p>Yet I can see from the standard out from the test that the path to my library is on the library path:</p>
  
  <pre><code>java.library.path=/test/lib
  </code></pre>
  
  <p>I've stripped the code back to the simplest setup and I still can't understand why the library is not loaded.  Could anyone advise what might be going wrong and how I might debug the issue more?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I played with this a lot yesterday, as mentioned I sanitised the full <code>java.library.path</code> for this post, but I noticed that it was fairly long.  Long in the total length, but also that each directory on it was fairly nested (possible 8/9 levels).  I reduced the path to only include the directory I knew where the <code>so</code> library was and it worked.</p>
  
  <p>Does anyone know of any <code>java.library.path</code> length constraints at all?</p>