I’m attempting to restructure a legacy application and reduce the steps needed to deploy.
To do this, I’m packaging all the class files, and Resources into a jar file.
I’m using this command to jar everything:
jar -cfm ../Deploy/JEmu.jar Manifest.txt *.class Resources/
My manifest file looks like this:
Manifest-Version: 1.0
Created-By: 1.2.2 (Sun Microsystems Inc.)
Main-Class: JEmu
Name: JEmu.class
The class that is the entry point is JEmu.class, which is packaged in the jar, but when I run the jar I get this error:
java -jar JEmu.jar
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at ControlBar.<init>(ControlBar.java:88)
at JEmu.<clinit>(JEmu.java:85)
Could not find the main class: JEmu. Program will exit.
I’m not exactly sure what is causing that.
Line 88 of ControlBar is:
stopButton = new JButton( new ImageIcon( classLoader.getResource("Resources/stop.gif")));
What am I doing wrong, it all works when it’s not packaged into a jar?
classLoader.getResource("Resources/stop.gif")probably cannot find the specified resource. When this happens, it returnsnull, hence theNullPointerException.