使用LauncherImpl.launchApplication

时间:2018-11-23 15:12:45

标签: java command-line executable-jar launcher preloader

我正在做一个应用程序,最近我用LauncherImpl.launchApplication(作为我的应用程序的预加载器)添加了一个初始屏幕。在此之前,我能够在命令行和Eclipse中运行该程序。现在,eclipse可以正常工作,但是没有更多的命令行。这是我的问题:为什么ide可以工作但cmd行不行?

我得到这些错误:

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 Preloader init method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:896)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Location is required.
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)
        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 view.MainPreloader.init(MainPreloader.java:22)
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:767)
        ... 2 more
Exception running application view.MainApp

此外,eclipse表示LauncherImpl.launchApplication:

禁止访问:方法“ LauncherImpl.launchApplication(Class,Class,String [])”不是API(对必需的库“ C:\ Program Files \ Java \ jdk1.8.0_161 \ jre \ lib \ ext \”的限制) jfxrt.jar')

我以前从未见过这样的错误,我是在互联网上发现的:Access restriction: The type 'Application' is not API (restriction on required library rt.jar)

但是在这个例子中,我不确定他们使用的是可执行jar。但是我必须使用一个。使用可执行jar,即使我按照说明更改了规则,也不起作用。

我们将不胜感激。

谢谢。

0 个答案:

没有答案