So, I'm creating a card game. To create the background image I create a level class from a bunch of different tiles. These tiles are selected from scanning a .png image: depending on the colors of the pixels of the image, the level tiles are selected.
I'm developing this in Eclipse, and running it from there has never been a problem.
However, when I tried exporting it as a runnable jar I couldn't start it by clicking it. So, I tried running it through windows command prompt instead. My program didn't run now either, but I got the following readout in the command prompt:
D:\The Documents\Programmering\Project\ProjectAI>java -jar ProjectAI1.jar Exception in thread "main" java.lang.IllegalArgumentException: input == null! at javax.imageio.ImageIO.read(Unknown Source) at org.geec.bluffai.level.Level.loadLevel(Level.java:40) at org.geec.bluffai.level.Level.<init>(Level.java:26) at org.geec.bluffai.graphics.Screen.<init>(Screen.java:23) at org.geec.bluffai.Coordinator.<init>(Coordinator.java:35) at org.geec.bluffai.Starter.main(Starter.java:10)
I then went to check my loadLevel method and it looked like this: [Java] Loadlevel first - Pastebin.com (Note that I do not know really anything about the try-catch block or exception-throwing in general.)
I did some google searches and changed my catch statement to
catch (IllegalArgumentException | IOException e)
so that my loadLevel method now looks like: [Java] Loadlevel second - Pastebin.com
I then exported it as a new executable jar and ran it again. This time it started. However, when using the command prompt to run it I got these readouts:
D:\The Documents\Programmering\Project\ProjectAI>java -jar ProjectAI2.jar [ERROR] Can't load level. java.lang.IllegalArgumentException: input == null! at javax.imageio.ImageIO.read(Unknown Source) at org.geec.bluffai.level.Level.loadLevel(Level.java:40) at org.geec.bluffai.level.Level.<init>(Level.java:26) at org.geec.bluffai.graphics.Screen.<init>(Screen.java:23) at org.geec.bluffai.Coordinator.<init>(Coordinator.java:35) at org.geec.bluffai.Starter.main(Starter.java:10) [ERROR] Can't load level. java.lang.IllegalArgumentException: input == null! at javax.imageio.ImageIO.read(Unknown Source) at org.geec.bluffai.level.Level.loadLevel(Level.java:40) at org.geec.bluffai.level.Level.<init>(Level.java:26) at org.geec.bluffai.graphics.Screen.<init>(Screen.java:23) at org.geec.bluffai.Coordinator.start(Coordinator.java:43) at org.geec.bluffai.Starter.main(Starter.java:12)
While the game is now runnable, the problem is still there. I would want to fix this but I do not know how to, as I do not know why I'm receiving these errors while running the game as an executable, but not while running it in Eclipse. As such I wonder if anyone have any idea of what the cause could be or how I could fix it?