导出的Javafx应用程序不作为Jar文件运行(Eclipse)

时间:2017-01-06 11:26:41

标签: java eclipse javafx jar manifest

我有一个javafx应用程序,它没有从eclipse正确导出到runnable jar文件。导出时.jar文件未正确运行且GUI未显示。下面是清单文件。

Manifest-Version: 1.0
Class-Path: .
Main-Class: gameaspects.SourceCodeVersion9

这是导出界面: enter image description here

导出文件不会产生错误或来自eclipse的警告。

从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 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(Unknown Source)
Caused by: java.nio.file.NoSuchFileException: .\music
    at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
    at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
    at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
    at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(Unknown Source)
    at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(Unknown Source)
    at sun.nio.fs.WindowsFileSystemProvider.readAttributes(Unknown Source)
    at java.nio.file.Files.readAttributes(Unknown Source)
    at java.nio.file.FileTreeWalker.getAttributes(Unknown Source)
    at java.nio.file.FileTreeWalker.visit(Unknown Source)
    at java.nio.file.FileTreeWalker.walk(Unknown Source)
    at java.nio.file.FileTreeIterator.<init>(Unknown Source)
    at java.nio.file.Files.find(Unknown Source)
    at gameaspects.SourceCodeVersion9.start(SourceCodeVersion9.java:81)
    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

异常运行应用程序gameaspects.SourceCodeVersion9

我认为这是指代码:

List<String> result = Files.find(Paths.get(".\\music"), 100,
        (p, a) -> p.toString().toLowerCase().endsWith(".mp3"))
        .map(path -> path.toString())
        .collect(Collectors.toList());

。\ music指的是我的应用程序中存在的源文件夹music

如果需要任何其他信息来诊断此问题,请在下面发表评论,我将添加它。

1 个答案:

答案 0 :(得分:1)

在命令提示符下使用java -jar FileName.jar然后使用堆栈跟踪调试我的代码,我可以在我的应用程序中找到错误。