Game works on netbeans but not outside netbeans in jar file?
- by Michael Haywood
I am creating a basic game of 'Pong'. I have finished the game apart from a few glitches I need to remove. The game runs perfectly in netbeans but if I create a jar file errors come up causing it to not work.
I am quite new to java but I believe it is something to do with my code looking for the images but the images have not been loaded up yet. Here is the error.
How can I get this to work outside of netbeans in a jar file?
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)