Surprisingly, you can also use the following:
final File dll = new File("src/lib/Tester32.dll"); Test32 test32 = (Test32) Native.loadLibrary(dll.getAbsolutePath(), Test32.class); System.out.println(test32.toString() + " - " + test32.GetLastError());
It outputs:
Proxy interface to Native Library <C:\workspace\jna\src\lib\ Tester32.dll@387842048 > - 0
Javadok says:
Loadlibrary
public static object loadLibrary (row name, Class interfaceClass)
Map the library interface to the shared library data, providing an explicit interface class. If the name is null, try to map to the current process.
If I rename Tester32.dll to the .\src\lib folder for something else, the following exception will occur:
Exception in the thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'C: \ workspace \ jna \ SRC \ Lib \ Tester32.dll': The specified module could not be found.
source share