2012-12-23 58 views
3

當試圖在ubuntu linux上運行基本的javafx應用程序時,出現以下錯誤。使用命令行或netbeans運行應用程序時出現錯誤。使用netbeans時Ubuntu上的Javafx錯誤

Exception in thread "main" java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Can't load library: /home/venkat/.m2/repository/com/oracle/javafx/javafx/2.1.0-beta/i386/libglass.so 
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:277) 
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:90) 
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:722) 
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: /home/venkat/.m2/repository/com/oracle/javafx/javafx/2.1.0-beta/i386/libglass.so 
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1828) 
at java.lang.Runtime.load0(Runtime.java:792) 
at java.lang.System.load(System.java:1059) 
at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoader.java:143) 
at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:56) 
at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:31) 
at com.sun.glass.ui.Application$1.run(Application.java:75) 
at java.security.AccessController.doPrivileged(Native Method) 
at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:73) 
at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:85) 
at com.sun.glass.ui.gtk.GtkPlatformFactory.<clinit>(GtkPlatformFactory.java:23) 
at java.lang.Class.forName0(Native Method) 
at java.lang.Class.forName(Class.java:186) 
at com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:20) 
at com.sun.glass.ui.Application.Run(Application.java:108) 
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:267) 
... 5 more 

回答

6

此異常是由於maven無法在類路徑中找到本機庫而引起的。

Netbeans的

您可以通過將運行配置文件裏面JVM參數解決問題。

-Djava.library.path=/home/venkat/Programs/javafx/2.1.0-beta/rt/lib/i386/

圖片

enter image description here

命令行

如果你試圖運行在命令行應用程序面臨同樣的問題,下面的出口應該可以解決它。上述

export JAVAFX_HOME=/home/venkat/Programs/javafx/2.1.0-beta 

export CLASSPATH=\$JAVAFX_HOME/rt/lib/jfxrt.jar 

export LD_LIBRARY_PATH=/home/venkat/Programs/javafx/2.1.0-beta/rt/lib/i386/ 

前兩個ENV變量固定時JavaFX運行無法找到這被看作一個類路徑問題。