JNA仅在Windows选项卡上运行时不满意链接错误

时间:2015-11-26 09:11:43

标签: java windows exception native jna

我正在尝试使用JNA从我的Java代码加载C dll。关注的路线是

rlib = (rfidlib) Native.loadlibrary("rfidlib",rfidlib.class);

我将DLL放在Windows机器的同一文件夹中并运行它。它运行正常。当我把它放在Windows / System32文件夹中也工作正常。但是当我将其复制到Windows选项卡时,它会抛出以下异常。

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: The speci

无法找到fied模块。

    at com.sun.jna.Native.open(Native Method)
    at com.sun.jna.Native.open(Native.java:1759)
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:260)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Library$Handler.<init>(Library.java:147)
    at com.sun.jna.Native.loadLibrary(Native.java:412)
    at com.sun.jna.Native.loadLibrary(Native.java:391)
    at com.kube.rfid.RFIDScanner.start(RFIDScanner.java:128)
    at com.kube.rfidscannertest.RFIDFrameMain$3.actionPerformed(RFIDFrameMai
n.java:106)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$400(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

选项卡和DLL中的Java版本都是64位版本。我已经尝试将jar保存在选项卡中的System32文件夹以及jar执行位置。我仍然得到这个错误。我该如何解决这个问题?请指教。它在我的Windows机器上运行良好。

1 个答案:

答案 0 :(得分:0)

这是因为缺少C DLL的依赖项。使用依赖性walker来识别依赖关系,一旦安装它们就可以工作。