簡體   English   中英

似乎無法在Eclipse中運行JavaFX項目

[英]Can't seem to run JavaFX project in Eclipse

我使用的是Ubuntu 14.04 64位。 我安裝了Java Java-8,並從http://efxclipse.bestsolution.at/下載了e(fx)clipse軟件包。

但是,現在我遇到了以下錯誤消息:

Exception in Application constructor
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)

Caused by: java.lang.RuntimeException: Unable to construct Application instance: class ui.project.Main
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:907)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:819)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$50(GtkApplication.java:139)
    ... 1 more

Caused by: java.lang.NoClassDefFoundError: com/sun/javafx/Utils
    at org.controlsfx.tools.Platform.getCurrentPlatform(Platform.java:65)
    at org.controlsfx.tools.Platform.<clinit>(Platform.java:41)
    at org.controlsfx.dialog.HeavyweightDialog.<clinit>(HeavyweightDialog.java:72)
    at org.controlsfx.dialog.DialogFactory.createDialog(DialogFactory.java:58)
    at org.controlsfx.dialog.Dialog.<init>(Dialog.java:295)
    at org.controlsfx.dialog.Dialogs.buildDialog(Dialogs.java:1086)
    at org.controlsfx.dialog.Dialogs.showCommandLinks(Dialogs.java:692)
    at ui.project.Main.welcomeWindow(Main.java:175)
    at ui.project.Main.<init>(Main.java:64)
    ... 13 more

Caused by: java.lang.ClassNotFoundException: com.sun.javafx.Utils
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 22 more
Exception running application ui.project.Main

在第175行中,主要的64個調用方法welcomeWindow包括以下行:

Action response = Dialogs.create()
            .title("Welcome to the Dolphin UI")
            .masthead(null)
            .message("Please select an option to proceed.")
            .showCommandLinks(links.get(3), links);

問題在於Java 8更新60中將類com.sun.javafx.Utils移到了com.sun.javafx.util.Utils包中。

我看到您在代碼中使用了ControlsFX。 然后,采用新版本的ControlsFX解決此問題。

更多信息: https : //bitbucket.org/controlsfx/controlsfx/issues/526/comsunjavafxutils-changes-to

使用三個不同的操作系統(Ubuntu 32、64和Windows 8.1)在此上花費了大約8個小時后,問題出在Java上。 顯然,8u40之后的任何版本均不適用於此版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM