EXE JAR无法按预期运行

时间:2013-03-07 18:21:35

标签: java netbeans-7 executable-jar

我使用.exe应用程序(NetBeans 7.1.2 JDK7)创建了我项目的JartoExe jar文件。现在某些类的工作正常。但它没有显示GUI /并在特定课程之后。

我已经包含了所有需要的依赖项。但是在一个特定的类之后GUI不会出现。.exe文件有什么问题?我错过了什么吗?

更新 在控制台上,它抛出FileNotFound Exception.My文件在当前项目文件夹中。那么,我需要更改什么?

这是因为getClass().getResourceAsStream()

异常详情:

Mar 07, 2013 10:57:07 PM projectfinal.KaraokeTest$3 run
SEVERE: null
java.io.FileNotFoundException: Na Kajre Ki Dhar.txt (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.util.Scanner.<init>(Unknown Source)
    at projectfinal.KaraokeTest.initComponents(KaraokeTest.java:89)
    at projectfinal.KaraokeTest.<init>(KaraokeTest.java:35)
    at projectfinal.KaraokeTest$3.run(KaraokeTest.java:375)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

1 个答案:

答案 0 :(得分:0)

jars通常没有目录。所以getClass().getResourceAsStream(somefile)应该是getClass().getResourceAsStream("\somefile")