How to launch java swing app which used precompled

2019-09-08 20:02发布

问题:

When i'm using double click my java app starts perfectly. My path:

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

But when i'm running app from 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)

i am trying to run with x86 java version:

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)

if i am trying to specify 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)

What i am doing wrong? Help please.

回答1:

1.) -Djava.library.path specifies the path to where native libraries live, it doesn't specify the libraries themselves. (i.e. - take the filename out, change it to -Djava.library.path="C:\Use rs\zagorulkinde\Documents\ps_client_lib\bin\Win32\")

2.) Case-sensitivity might be an issue - you're referencing the file as "Pc_client_lib.dll" and "PC_client_lib" in different places. Make sure the name you use in loadLibrary has the same case as the actual .DLL file name.



回答2:

You have to put your DLL to place where JVM can find it. Typically it should be located under your application folder but you should specify option -Djava.library.path=PATH TO YOUR DLL when you are running java.



回答3:

Safest way is to put your DLL file into system32 folder.