无法执行JAR文件

时间:2019-02-02 18:45:18

标签: java mysql

我学习Java和我创建了我的第一个Java项目,这仅仅是UPI的演示应用程序。我的项目在IDE(使用Netbeans IDE)中可以完美运行,但是当我创建JAR文件并尝试执行该文件时,它显示此错误:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(Unknown Source)
    at swift.upi.LoginUI.initComponents(LoginUI.java:350)
    at swift.upi.LoginUI.<init>(LoginUI.java:27)
    at swift.upi.Welcome.nextBtnMouseClicked(Welcome.java:133)
    at swift.upi.Welcome.access$000(Welcome.java:14)
    at swift.upi.Welcome$1.mouseClicked(Welcome.java:67)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(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$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.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)

当我尝试执行任何事件(例如鼠标单击事件)时,会发生此错误。 正因为如此,我才能够运行我的内部IDE项目。 试图解释一个简单易用的方式问题和解决方案。 我给的链​​接到我的项目为了方便起见,找到 here

谢谢。

1 个答案:

答案 0 :(得分:0)

正如卡洛斯(Carlos)的评论所暗示的那样,问题在于找到LoginUI.java第350行中引用的图标/图像。

将压缩后的项目内容与类I guess 的代码进行比较,可能是文件名及其大小写出现了问题。

  • 代码说/swift/upi/Name logo.jpg
  • 该目录包含名为Name Logo.jpg的文件

尝试将l更改为L。 另外-我建议您在文件名中避免使用空格字符。