Windows, JNA: Cannot load native library - UnsatisfiedLinkError
<p>I am using <strong>Java 7</strong> on <strong>Windows 7</strong> and am trying to use Java <strong>JNA</strong> (Java Native Access) (4.2.2) [ link: <a href="https://github.com/java-native-access/jna" rel="nofollow">https://github.com/java-native-access/jna</a> ] to provide access to a <strong>C language native library</strong>. I have done this on a Linux system and have no problems finding and loading the library.</p>

<p>I am using the suggested technique of setting the system property <strong>jna.library.path</strong> to the path where the library is located. As mentioned above, this works on Linux, but on Windows I cannot get it to find and load the library.</p>

<p>On the Windows platform, the library comes in both 32 and 64 bit variants (I'm trying to use the 32-bit), with both .lib and .dll files.</p>

<p>I also set the system properties <strong>jna.debug_load</strong> and <strong>jna.debug_load.jna</strong> to <strong>true</strong> as suggested to watch how JNA does its thing.</p>

<p>I have tried the following to no avail:</p>

<ul>
<li>System.setProperty("jna.library.path", "C:\Program Files
(x86)\VMware\VMware VIX"); (<em>Windows style path</em>)</li>
<li>System.setProperty("jna.library.path",
"C:/Program Files (x86)/VMware/VMware VIX"); (<em>UNIX style path</em>)</li>
<li>I placed the library in a path that has no spaces in it.</li>
<li>I added the library name on the path (with and without file extension). E.g. "C:\Program Files (x86)\VMware\VMware VIX\VixAllProductsDyn". (VixAllProductsDyn.dll)</li>
</ul>

<p>When I make an attempt, I can see the debug information on the Java console. Oddly, it tries the exact path to where the library file sits - <strong>and yet does not find it</strong>.</p>

<p>If anyone has run into this and knows anything about solving the problem, it would be much appreciated.</p>

<pre><code>Trying (via loadLibrary) jnidispatch
Looking in classpath from sun.misc.Launcher$AppClassLoader@1a1a7aa4 for /com/sun/jna/win32-x86-64/jnidispatch.dll
Found library resource at jar:file:/C:/Users/jo24447/.m2/repository/net/java/dev/jna/jna/4.2.2/jna-4.2.2.jar!/com/sun/jna/win32-x86-64/jnidispatch.dll
Trying C:\Users\jo24447\AppData\Local\Temp\jna--734724592\jna8544680981267090708.dll
Found jnidispatch at C:\Users\jo24447\AppData\Local\Temp\jna--734724592\jna8544680981267090708.dll
Looking for library 'VixAllProductsDyn'
Adding paths from jna.library.path: C:\Program Files (x86)\VMware\VMware VIX
Trying C:\Program Files (x86)\VMware\VMware VIX\VixAllProductsDyn.dll
Adding system paths: []
Trying C:\Program Files (x86)\VMware\VMware VIX\VixAllProductsDyn.dll
Looking for lib- prefix
Trying libVixAllProductsDyn.dll
Looking in classpath from sun.misc.Launcher$AppClassLoader@1a1a7aa4 for VixAllProductsDyn
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'VixAllProductsDyn': Native library (win32-x86-64/VixAllProductsDyn.dll) not found in resource path ([file:/C:/Users/jo24447/luna_workspace/VMUtil/vm-util/target/classes/, file:/C:/Users/jo24447/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar, file:/C:/Users/jo24447/.m2/repository/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar, file:/C:/Users/jo24447/.m2/repository/org/slf4j/slf4j-log4j12/1.7.2/slf4j-log4j12-1.7.2.jar, file:/C:/Users/jo24447/.m2/repository/net/java/dev/jna/jna/4.2.2/jna-4.2.2.jar, file:/C:/Users/jo24447/.m2/repository/net/java/dev/jna/jna-platform/4.2.2/jna-platform-4.2.2.jar])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:277)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:342)
    at edu.mit.ll.oms.security.vm.VIXLibrary.&lt;clinit&gt;(VIXLibrary.java:24)
    at edu.mit.ll.oms.security.vm.test.QuickTest.main(QuickTest.java:16)
</code></pre>