0

我已经.exe使用应用程序(NetBeans 7.1.2 JDK7)创建了我的项目的 jar 文件JartoExe。现在对于某些类它工作得很好。但它没有显示特定类的/和之后的 GUI。

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

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

这是因为 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)
4

1 回答 1

0

很多时候 jars 没有目录。所以getClass().getResourceAsStream(somefile)应该是getClass().getResourceAsStream("\somefile").

于 2013-03-08T11:14:55.707 回答