我正在创建一个基本的“乒乓球”游戏。我已经完成了游戏,除了一些我需要删除的小故障。游戏在 netbeans 中运行完美,但如果我创建一个 jar 文件错误会导致它无法工作。我对java很陌生,但我相信这与我的代码寻找图像有关,但图像尚未加载。这是错误。我怎样才能让它在 jar 文件中的 netbeans 之外工作?
C:\Users\michael>java -jar "C:\Users\michael\Documents\NetBeansProjects\Pong\dis
t\Pong.jar"
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at pong.BallMainMenu.<init>(BallMainMenu.java:19)
at pong.Board.gameInit(Board.java:93)
at pong.Board.addNotify(Board.java:86)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at javax.swing.JRootPane.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at java.awt.Window.addNotify(Unknown Source)
at java.awt.Frame.addNotify(Unknown Source)
at java.awt.Window.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at pong.Pong.<init>(Pong.java:16)
at pong.Pong.main(Pong.java:23)