2013-05-14 62 views
3

我正在嘗試學習javafx。我有一個非常簡單的程序在主要方法(作爲測試)中打印「Hello World」一次,並在應用程序中打印一次。代碼如下所示:UnsatisfiedLinkError與javafx

import javafx.stage.*; 
import javafx.application.*; 

public class HelloApp extends Application 
{ 
    public static void main(String[] args) 
    { 
     System.out.println("Hello World"); 
     launch(args); 
    } 

    public void start(Stage stage) 
    { 
     System.out.println("Hello World"); 
    } 
} 

這給了我以下輸出。請注意,它會打印第一個「Hello World」,但不是第二個。

--------------------Configuration: javafx trials - JDK version 1.6.0_07 <Default> - <Default>-------------------- 
Hello World 
Exception in thread "main" java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Can't load library: C:\Documents and Settings\apcs.LGSUHSD\My Documents\JCreator LE\MyProjects\bin\glass.dll 
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:281) 
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:124) 
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:163) 
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47) 
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115) 
at java.lang.Thread.run(Thread.java:619) 
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: C:\Documents and Settings\apcs.LGSUHSD\My Documents\JCreator LE\MyProjects\bin\glass.dll 
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1650) 
at java.lang.Runtime.load0(Runtime.java:770) 
at java.lang.System.load(System.java:1005) 
at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoader.java:200) 
at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:88) 
at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:31) 
at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:73) 
at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:80) 
at com.sun.glass.ui.win.WinApplication$1.run(WinApplication.java:36) 
at com.sun.glass.ui.win.WinApplication$1.run(WinApplication.java:33) 
at java.security.AccessController.doPrivileged(Native Method) 
at com.sun.glass.ui.win.WinApplication.<clinit>(WinApplication.java:33) 
at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatformFactory.java:20) 
at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatformFactory.java:17) 
at com.sun.glass.ui.Application.Run(Application.java:103) 
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:271) 
... 5 more 

Process completed. 

我不知道爲什麼會發生這種情況。我在項目中有javafx的jar文件。有人能解釋爲什麼會發生這種情況,我能做些什麼?

+2

請參考這個類似問題的答案http://stackoverflow.com/questions/11349303/how-to-make-jar-file-from-javafx-project –

回答

1

如果您正在使用eclipse,請將C:\ Program Files \ Oracle \ JavaFX Runtime \ lib \ jfxrt.jar作爲外部jar和重建項目。

+0

需要先安裝JavaFX SDK? – ADTC