I am trying to create a runnable jar file .. did a few days ago with a single class and worked fine but now it doesn't seem to be working as good with multiple files .. Here is what I did
1) - create manifest.txt the contense of it is Main-class: HangmanLogic
2) - use this command in cmdC:\Users\User\eclipse\Hangman> jar cvfm Hangman.jar manifest.txt HangmanLogic.class Hangman.class
that returns this in command line:
added manifiest
adding: HangmanLogic.class(in = 3920) (out= 2155)(deflated 45%)
adding: Hangman.class(in = 4700) (out= 2314)(deflated 50%)
3) when I try to run the jar file now using java -jar Hangman.jar
I get the following errors
C:\Users\User\eclipse\Hangman>java -jar Hangman.jar
The word is trap and the hint is hint
[ _ , _ , _ , _ ]
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at Hangman.<init>(Hangman.java:17)
at HangmanLogic.<clinit>(HangmanLogic.java:10)
I think it has to do something with the manifest file? Not sure if its supposed to return "Added manifest"
It points to this location in the code in Hangman.java
private ImageIcon img = new ImageIcon(getClass().getResource("images.jpg"));
private Icon hanged0 = new ImageIcon( getClass().getResource( "0.png" ));
private Icon hanged1 = new ImageIcon( getClass().getResource( "11.PNG" ));
private Icon hanged2 = new ImageIcon( getClass().getResource( "22.PNG" ));
private Icon hanged3 = new ImageIcon( getClass().getResource( "33.PNG" ));
private Icon hanged4 = new ImageIcon( getClass().getResource( "44.PNG" ));
private Icon hanged5 = new ImageIcon( getClass().getResource( "55.PNG" ));
and in HangmanLogic.javaprivate static Hangman hmGUI = new Hangman();