繁体   English   中英

我的 JavaFX 应用程序中的应用程序启动方法错误中的异常 [重复]

[英]Exception in Application Start Method Error in my JavaFX application [duplicate]

我知道以前有人问过这个问题,但答案无法帮助解决问题。 我实际上没有错误,但我无法运行我的应用程序。

"C:\Program Files\Java\jdk-18\bin\java.exe" "-

javaagent:D:\IntelliJ IDEA Educational Edition 2021.3.2\lib\idea_rt.jar=59011:D:\IntelliJ IDEA Educational Edition 2021.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-controls\18-ea+6\javafx-controls-18-ea+6.jar;C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-graphics\18-ea+6\javafx-graphics-18-ea+6.jar;C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-base\18-ea+6\javafx-base-18-ea+6.jar;C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-fxml\18-ea+6\javafx-fxml-18-ea+6.jar;C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-web\18-ea+6\javafx-web-18-ea+6.jar;C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-media\18-ea+6\javafx-media-18-ea+6.jar" -p "C:\Users\Loni Tande\Desktop\CalApp\target\classes;C:\Users\Loni Tande\.m2\repository\com\dlsc\formsfx\formsfx-core\11.3.2\formsfx-core-11.3.2.jar;C:\Users\Loni Tande\.m2\repository\org\controlsfx\controlsfx\11.1.0\controlsfx-11.1.0.jar;C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-controls\18-ea+6\javafx-controls-18-ea+6-win.jar;C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-media\18-ea+6\javafx-media-18-ea+6-win.jar;C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-base\18-ea+6\javafx-base-18-ea+6-win.jar;C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-web\18-ea+6\javafx-web-18-ea+6-win.jar;C:\Users\Loni Tande\.m2\repository\org\kordamp\ikonli\ikonli-core\12.2.0\ikonli-core-12.2.0.jar;C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-fxml\18-ea+6\javafx-fxml-18-ea+6-win.jar;C:\Users\Loni Tande\.m2\repository\org\kordamp\bootstrapfx\bootstrapfx-core\0.4.0\bootstrapfx-core-0.4.0.jar;C:\Users\Loni Tande\.m2\repository\org\openjfx\javafx-graphics\18-ea+6\javafx-graphics-18-ea+6-win.jar;C:\Users\Loni Tande\.m2\repository\eu\hansolo\tilesfx\11.48\tilesfx-11.48.jar;C:\Users\Loni Tande\.m2\repository\org\kordamp\ikonli\ikonli-javafx\12.2.0\ikonli-javafx-12.2.0.jar;C:\Users\Loni Tande\.m2\repository\net\synedra\validatorfx\0.1.13\validatorfx-0.1.13.jar" -m com.example.calapp/com.example.calapp.HelloApplication
Exception in Application start method
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at javafx.graphics@18-ea/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:465)
    at javafx.graphics@18-ea/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1081)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at javafx.graphics@18-ea/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
    at javafx.graphics@18-ea/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalArgumentException: Invalid URL: unknown protocol: c
    at javafx.graphics@18-ea/javafx.scene.image.Image.validateUrl(Image.java:1135)
    at javafx.graphics@18-ea/javafx.scene.image.Image.<init>(Image.java:625)
    at com.example.calapp/com.example.calapp.HelloApplication.start(HelloApplication.java:16)
    at javafx.graphics@18-ea/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
    at javafx.graphics@18-ea/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
    at javafx.graphics@18-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at javafx.graphics@18-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
    at javafx.graphics@18-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics@18-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics@18-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
    ... 1 more
Caused by: java.net.MalformedURLException: unknown protocol: c
    at java.base/java.net.URL.<init>(URL.java:681)
    at java.base/java.net.URL.<init>(URL.java:569)
    at java.base/java.net.URL.<init>(URL.java:516)
    at javafx.graphics@18-ea/javafx.scene.image.Image.validateUrl(Image.java:1132)
    ... 11 more
Exception running application com.example.calapp.HelloApplication
Process finished with exit code 1

以上是我得到的错误。 我不知道该怎么办。

这是我的主java class的截图。

在像这样使用它之前,您必须在文件 object 中加载图像

File file = new File("c:\\files\\image.png");
Image image = new Image(file.toURI().toString());

暂无
暂无

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

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