Hi,
I am creating a runnable/executable jar for a program that uses some image files on disk. When I hard-code the explicit location of the files, the jar executes just fine. But since the end users won't have the image files (and even if they did, they would not be located in the same place as my code points to), I want to make a relative reference to the location, and include them in the jar.
Here is the code I am using:
No matter where I place the image files, they do not end up in the jar, and therefore the jar crashes with the following exception:
Exception in
thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at com.russ.Board.<init>(Board.java:28)
at com.russ.GameApp.main(GameApp.java:8)
There is no place in Eclipse to "Add Files" to the jar.
My class files are located at: C:\JavaCode\Game\bin\com\russ
I tried putting the image files in each of those sub-directories and they never end up in the jar.
Why aren't the image files being included in the jar? What am I doing wrong? Any help is appreciated.
Thanks in advance,
-Russ S.