Game works on netbeans but not outside netbeans in jar file?
Posted
by
Michael Haywood
on Programmers
See other posts from Programmers
or by Michael Haywood
Published on 2012-09-24T22:03:57Z
Indexed on
2012/09/25
3:49 UTC
Read the original article
Hit count: 387
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)
© Programmers or respective owner