This came up when developing under windows.
I have have many native libraries. 2 for each platform [1 for 32 bit and 1 for 64 bit] that I am supporting.
I am shipping the those libraries within the jar. Only one of those libs will work so naturally I only want one file outside the jar. What I did was write the appropriate resource to a file with a generic name "library".
As you can see there is no extension. The file does not adhere to any of the platform specific naming rules. So I passed the absolute file path to
NativeLibrary.getInstance(String)
but this will end up with
java.lang.UnsatisfiedLinkError: Unable to load library 'C:\mypath\library' : The specified module could not be found.
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:194)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:283)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:244)
even though the file is right there.
Changing the file's name to "library.dll" will have JNA load it correctly.
I initially was using a temporary file (File.createTempFile() and had the same issue because I left the extension as ".tmp".
So here is the request:
When an absolute path name is supplied please allow the file to be loaded no matter what the name is.
Thanks
This came up when developing under windows.
I have have many native libraries. 2 for each platform [1 for 32 bit and 1 for 64 bit] that I am supporting.
I am shipping the those libraries within the jar. Only one of those libs will work so naturally I only want one file outside the jar. What I did was write the appropriate resource to a file with a generic name "library".
As you can see there is no extension. The file does not adhere to any of the platform specific naming rules. So I passed the absolute file path to
but this will end up with
even though the file is right there.
Changing the file's name to "library.dll" will have JNA load it correctly.
I initially was using a temporary file (File.createTempFile() and had the same issue because I left the extension as ".tmp".
So here is the request:
When an absolute path name is supplied please allow the file to be loaded no matter what the name is.
Thanks