I'm working on a game in Java and it runs as expected in Eclipse but when I export it as an executable jar, I get a null pointer exception when I try to call the listFiles( ) method of the File class. Here is the code:
File Buffer = new File( "Resources/SpriteSheets" );
// Count how many sprite sheets there are
m_intTotalSheetCount = Buffer.listFiles( ).length;
Here's the error:
C:\Users\Joe>java -jar C:\Users\Joe\Documents\GameDevelopment\Game1.jar
Exception in thread "Thread-2" java.lang.NullPointerException
at Graphics.CSpriteSheetLoader.<init>(CSpriteSheetLoader.java:25)
at Graphics.CScreen.<init>(CScreen.java:36)
at game.CGame.Initialize(CGame.java:107)
at game.CGame.run(CGame.java:157)
at java.lang.Thread.run(Thread.java:722)
I looked in the jar file and there isn't even a resource folder there, so I also tried File( "SpriteSheets" ), but I got the same error