尝试到达jar路径时调用异常

时间:2017-06-23 10:41:02

标签: java intellij-idea javafx

我得到了这个例外:

"C:\Program Files\Java\jdk1.8.0_121\bin\java" -Dfile.encoding=windows-1254 -jar C:\Users\Jeredriqs\IdeaProjects\Exporter\out\artifacts\Exporter\Exporter.jar
Exception in Application start method
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:498)
    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:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
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$155(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
    at sample.Main.start(Main.java:213)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191)
    ... 1 more
Exception running application sample.Main

Process finished with exit code 1

但我查看了我的代码,无法理解为什么会发生这种情况。它适用于普通的java类,但由于某种原因无法运行jar文件。

异常中提及的行是:

  

文件fileQueries = new    File(this.getClass()。getClassLoader()。getResource(“”)。getPath()+“\ Config \ Queries.ini”);

    File fileProfiles = new File(this.getClass().getClassLoader().getResource("").getPath() + "\\Config\\Config.properties");

    if (fileQueries != null && !fileQueries.toString().isEmpty() && fileQueries.exists() && !fileQueries.isDirectory()) {


        QueryManager queryManager = new QueryManager();
        queryManager.readQueries(fileQueries.toString(), ";");
        comboQueries = queryManager.comboQueries;
        if (queryManager.isSuccessSql) {
            arrayNames = new String[comboQueries.size()];
            arrayQueries = new String[comboQueries.size()];
            int index = 0;
            for (ComboQuery cmb : comboQueries) {
                arrayNames[index] = cmb.getName();
                arrayQueries[index] = cmb.getQuery();
                index++;
            }
            cmbQuery.getItems().addAll(arrayNames);

        }


    } else {

        fileQueries.getParentFile().mkdirs();
        fileQueries.createNewFile();
        FileOutputStream fileOutputStream = new FileOutputStream(fileQueries, false);

    }

任何帮助都将不胜感激。

0 个答案:

没有答案