JNA-设置资源路径 [英] JNA - Set resource Path

查看:862
本文介绍了JNA-设置资源路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置JNA以与我拥有的自定义DLL通讯,但无济于事

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

它一直在说它正在查找lcoation中的资源路径/ target / classes /

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

我想知道是否可以添加一个可以获取我的DLL的资源位置?

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

我的代码如下

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);

如果我手动将dll添加到/ target / classes /文件夹中,则DLL将按预期加载

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

我正在使用Eclipse Luna 32位
JDK 1.7.0_65 32位
JNA 4.1.0

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

任何帮助都将受到感激

感谢
Damien

Thanks Damien

推荐答案

JNA查找系统属性 jna.library.path 指定的位置,回退到 java.library中的任何路径。路径,否则(通常是基于环境中的 PATH 设置的。)

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).

您应该确保eclipse将DLL复制到应用程序最终希望找到的位置,并且还应确保eclipse在启动时将 jna.library.path 正确设置到该位置。

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.

还请注意,任何依赖库都必须通过 PATH 或与目标位于同一目录中DLL。

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

请参见 JavaDoc for NativeLibrary 的其他变化JNA可以在其中加载您的本机库。

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

这篇关于JNA-设置资源路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆