2015-11-26 29 views
0

我想從我的Java代碼使用JNA加載C DLL。有關的行是只有當在Windows標籤上運行JNA不滿意的鏈接錯誤

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機器中工作正常。

+0

你是什麼意思的「Windows標籤」? – technomage

+0

其安裝了Windows 8.1的選項卡。 – mayooran

+0

你的意思是「平板電腦」?將系統屬性'jna.library.path'設置爲指向DLL所在的目錄。 – technomage

回答

0

這是因爲C DLL的依賴關係丟失了。使用依賴關係walker來識別依賴關係,一旦它們被安裝,它就可以工作。