JNA - Set resource Path

陌路散爱 提交于 2019-12-10 19:59:59

问题


I am trying to set up JNA to talk to a custom DLL i have but to no avail

It keeps saying it is looking in the resource path in the lcoation /target/classes/

I was wondering is it possible to add a resource location where it can pick up my DLL?

My code is as follows

System.setProperty("jna.debug_load", "true");
System.setProperty("jna.debug_load.jna", "true");

System.setProperty("jna.platform.library.path", "C:\\Development\\dll\\");

Native.loadLibrary("customDLL", CustomDLL.class);

If I manually add the dll to the folder /target/classes/, the DLL loads as expected

I am using Eclipse Luna 32bit JDK 1.7.0_65 32 bit JNA 4.1.0

Any help is greatly appreciated

Thanks Damien


回答1:


JNA looks in the location specified by the system property jna.library.path, falling back to whatever path is in java.library.path otherwise (which is mostly set based on PATH from the environment).

You should make sure that eclipse copies the DLL to wherever the application will eventually expect to find it, and also ensure the eclipse properly sets jna.library.path to that location when launching your JVM.

Note also that any dependent libraries must either by on PATH or in the same directory as your target DLL.

See the JavaDoc for NativeLibrary for other variations on where JNA can load your native library.



来源:https://stackoverflow.com/questions/25063614/jna-set-resource-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!