简体   繁体   English

JavaFX GUI 在 Netbeans IDE 上工作得很好,但在 eclipse 上不行

[英]A JavaFX GUI is working perfectly fine with Netbeans IDE, but not with eclipse

I made an Application with JavaFX and Scenebuilder in Netbeans and ist working perfectly fine, but as I try to run it with eclipse it won't work and only throws errors.我在 Netbeans 中使用 JavaFX 和 Scenebuilder 制作了一个应用程序,并且运行得非常好,但是当我尝试使用 eclipse 运行它时,它无法工作,只会引发错误。

I have java 8, eclipse 2019-09 R (4.13.0), and Scenebuilder for Java 8. Also, I have the e(fx)clipse addon for eclipse.我有 java 8、eclipse 2019-09 R (4.13.0) 和用于 Java 8 的 Scenebuilder。另外,我有 eclipse 的 e(fx)clipse 插件。

I can't understand why an IDE can make the difference, it is exactly the same code and Java我不明白为什么 IDE 可以有所作为,它的代码和 Java 完全相同

Exception in Application start method
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        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(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
        at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException:
/C:/Users/User1/eclipse-workspace/guitestFX/src/application/FXMLStart.fxml:10

        at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
        at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:103)
        at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:922)
        at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
        at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
        at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
        at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
        at application.Main.start(Main.java:29)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
        ... 1 more
Caused by: java.lang.ClassNotFoundException: FXMLStartController
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:920)
        ... 22 more
Exception running application application.Main

From comment @fabian:来自评论@fabian:

The name of the controller class seems to be wrong... Assuming did not place the controller class in the default package.控制器类的名字好像不对。。。假设没有把控制器类放在默认包里。 Use the fully qualified class name in the fx:controller attribute...在 fx:controller 属性中使用完全限定的类名...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM