当试图在ubuntu linux上运行一个基本的javafx应用程序时,我看到以下错误.使用命令行或netbeans运行应用程序时出现错误.
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
解决方法:
导致此异常是因为maven无法在类路径中找到本机库.
Netbeans的
您可以通过在运行配置文件中添加JVM参数来解决问题.
-Djava.library.path = /家庭/ venkat /程序/ JavaFX的/ 2.1.0-β/ RT / lib中/ I386 /
图片
命令行
如果您在尝试在命令行上运行应用程序时遇到同样的问题,则以下导出应该修复它.
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运行时时会出现这个问题.