0

我正在尝试在 Netbeans 7.0.1 中加载 DLL 文件,

代码是

dll = (RRHFEK02DLL)Native.loadLibrary("RRHFEK02DLL.dll", RRHFEK02DLL.class);
utility = (Utilities)Native.loadLibrary("Utilities.dll",Utilities.class);
wraper =(RRHFEK02Wrapper)Native.loadLibrary("RRHFEK02Wrapper.dll", RRHFEK02Wrapper.class);

第一行没有错误,这行在提供者的演示中,现在我想加载另外两个 dll,我已经添加了接下来的两行并在库中添加了 dll 文件,但是我得到了错误

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError:
Unable to load library 'Utilities.dll': The specified module could not
be found.
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:166)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:239)
    at com.sun.jna.Library$Handler.<init>(Library.java:140)
    at com.sun.jna.Native.loadLibrary(Native.java:393)
    at com.sun.jna.Native.loadLibrary(Native.java:378)
    at rrhfek02.RRHFEK02View.<init>(RRHFEK02View.java:87)
    at rrhfek02.RRHFEK02App.startup(RRHFEK02App.java:19)
    at org.jdesktop.application.Application$1.run(Application.java:171)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

我已经解决了相同/相关的问题,但没有得到解决方案。所以,如果有人有,请给我建议。

4

2 回答 2

1

您需要插入.dll扩展名(在 Mac 上不需要,如果扩展名是.framework. 在我的系统上,使用我的 netbeans 项目文件夹结构:

+ src
+ EDSDK
      -dll
          -EDSDK
      -headers
+Other Files

正在做:

this.EDSDK = (EdSdkLibrary) Native.loadLibrary("EDSDK/dll/EDSDK.dll", EdSdkLibrary.class

有效地加载它。在加载之前,您可以尝试new File("RRHFEK02DLL.dll").exists()返回什么。如果false,那么你的路径是错误的。如果true,那么问题是别的东西

于 2013-04-21T07:06:21.607 回答
0

".dll"在 Java 中删除。那是:

dll = (RRHFEK02DLL) Native.loadLibrary("RRHFEK02DLL", RRHFEK02DLL.class);
utility = (Utilities) Native.loadLibrary("Utilities", Utilities.class);
wraper = (RRHFEK02Wrapper) Native.loadLibrary("RRHFEK02Wrapper", RRHFEK02Wrapper.class);

不要修改您实际的 DLL 文件的名称!

于 2013-04-20T15:17:02.157 回答