0

当我使用双击时,我的 java 应用程序完美启动。我自己的路:

PATH=...C:\Program Files\Java\jdk1.7.0_02\bin;...

但是当我从 cmd 运行应用程序时:

C:\Program Files\Java\jdk1.7.0_02\bin>java.exe -jar C:\Users\zagorulkinde\Docume
nts\ps_client_lib\bin\Win32\GUItest.jar
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: C:\Window
s\System32\pc_client_lib.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform

        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1928)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1854)
        at java.lang.Runtime.loadLibrary0(Runtime.java:845)
        at java.lang.System.loadLibrary(System.java:1084)
        at PC_client.lib.<clinit>(lib.java:10)
        at settings.load(GUItest.java:342)
        at GUItest.createAndShowGUI(GUItest.java:2681)
        at GUItest.access$4100(GUItest.java:851)
        at GUItest$22.run(GUItest.java:2728)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
        at java.awt.EventQueue.access$000(EventQueue.java:101)
        at java.awt.EventQueue$3.run(EventQueue.java:666)
        at java.awt.EventQueue$3.run(EventQueue.java:664)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:211)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:128)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:117)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

我正在尝试使用 x86 java 版本运行:

C:\Program Files (x86)\Java\jdk1.7.0_09\bin>java.exe -jar C:\Users\zagorulkinde\
Documents\ps_client_lib\bin\Win32\GUItest.jar
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no PC_cli
ent_lib in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
        at java.lang.Runtime.loadLibrary0(Runtime.java:845)
        at java.lang.System.loadLibrary(System.java:1084)
        at PC_client.lib.<clinit>(lib.java:10)
        at settings.load(GUItest.java:342)
        at GUItest.createAndShowGUI(GUItest.java:2681)
        at GUItest.access$4100(GUItest.java:851)
        at GUItest$22.run(GUItest.java:2728)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
        at java.awt.EventQueue.access$200(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:682)
        at java.awt.EventQueue$3.run(EventQueue.java:680)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:244)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:163)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:151)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

如果我试图指定 dll:

C:\Program Files (x86)\Java\jdk1.7.0_09\bin>java.exe -Djava.library.path="C:\Use
rs\zagorulkinde\Documents\ps_client_lib\bin\Win32\Pc_client_lib.dll" -jar C:\Use
rs\zagorulkinde\Documents\ps_client_lib\bin\Win32\GUItest.jar
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no PC_cli
ent_lib in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
        at java.lang.Runtime.loadLibrary0(Runtime.java:845)
        at java.lang.System.loadLibrary(System.java:1084)
        at PC_client.lib.<clinit>(lib.java:10)
        at settings.load(GUItest.java:342)
        at GUItest.createAndShowGUI(GUItest.java:2681)
        at GUItest.access$4100(GUItest.java:851)
        at GUItest$22.run(GUItest.java:2728)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
        at java.awt.EventQueue.access$200(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:682)
        at java.awt.EventQueue$3.run(EventQueue.java:680)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:244)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:163)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:151)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

我做错了什么?请帮忙。

4

3 回答 3

2

您必须将 DLL 放在 JVM 可以找到的地方。通常,它应该位于您的应用程序文件夹下,但您应该-Djava.library.path=PATH TO YOUR DLL在运行 java.util 时指定选项。

于 2012-12-11T12:48:04.093 回答
1

1.) -Djava.library.path 指定本地库所在的路径,它不指定库本身。(即 - 取出文件名,将其更改为-Djava.library.path="C:\Use rs\zagorulkinde\Documents\ps_client_lib\bin\Win32\"

2.) 区分大小写可能是一个问题 - 您在不同的地方将文件称为“Pc_client_lib.dll”和“PC_client_lib”。确保您使用的名称loadLibrary与实际的 .DLL 文件名大小写相同。

于 2012-12-11T13:00:54.027 回答
0

最安全的方法是将您的 DLL 文件放入system32文件夹中。

于 2012-12-11T12:48:26.203 回答