Foxi4
I've been working on my first ever game in Java and am happy to say it is nearly complete!
I'm using Eclipse IDE and JRE 8 + JDK 8. Everything runs perfect in Eclipse, however my exported JAR does not run. Instead I get an "A Java Exception has occured." message popup.
I did some research and found you can run JAR's in CMD to find out what is causing the exception. So, here is the problem:
C:\Users\Marduk\Desktop>java -jar frog.jar
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(Unknown Source)
at Menu.loadBufferedImage(Menu.java:334)
at Menu.<init>(Menu.java:56)
at RunGame.<clinit>(RunGame.java:3)
Don't mind the RunGame part, it is not important it just calls everything (the main method)
The REAL problem is line 334, my BufferImage method.
So, here it is:
Again, this works perfectly in Eclipse. I even tried giving 'bi' a permanent one image, but no luck! It certainly messes up my images in my game while run the IDE though! (A sign that it is working)
For the sake of you understanding what is wrong with line 56-58, here is my code starting with Menu() in the class Menu.
FYI, I've also tried
BgPanel = loadBufferedImage("/bggfx/FrogGierStartScreengroundPanel_sd.png");
rather than \\, it produces the same effect.
So what is wrong? It is not the images... They load perfectly in Eclipse! Maybe the code on lines 56-58 is wrong though? Looking for any suggestions!
And yes, I'm exporting all my resources into the JAR when I "EXPORT" it in Eclipse.
I can get it to run but only if I take away all images that use loadBufferImage...
Very strange.
Also audio does not play... Seems like it can't find the resources :|
Most Likely this is the culprit:
at javax.imageio.ImageIO.read(Unknown Source)
I've been working on my first ever game in Java and am happy to say it is nearly complete!
I'm using Eclipse IDE and JRE 8 + JDK 8. Everything runs perfect in Eclipse, however my exported JAR does not run. Instead I get an "A Java Exception has occured." message popup.
I did some research and found you can run JAR's in CMD to find out what is causing the exception. So, here is the problem:
C:\Users\Marduk\Desktop>java -jar frog.jar
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(Unknown Source)
at Menu.loadBufferedImage(Menu.java:334)
at Menu.<init>(Menu.java:56)
at RunGame.<clinit>(RunGame.java:3)
Don't mind the RunGame part, it is not important it just calls everything (the main method)
The REAL problem is line 334, my BufferImage method.
So, here it is:
Code:
private BufferedImage loadBufferedImage(String string) {
try {
BufferedImage bi = ImageIO.read(this.getClass().getResource(string));
return bi;
} catch (IOException e) {
}
return null;
}
Again, this works perfectly in Eclipse. I even tried giving 'bi' a permanent one image, but no luck! It certainly messes up my images in my game while run the IDE though! (A sign that it is working)
Code:
private BufferedImage loadBufferedImage(String string) {
try {
BufferedImage bi = ImageIO.read(this.getClass().getResource("\\bggfx\\FrogGierStartScreengroundPanel_sd.png"));
return bi;
} catch (IOException e) {
}
return null;
}
For the sake of you understanding what is wrong with line 56-58, here is my code starting with Menu() in the class Menu.
Code:
public Menu() {
int screenRes = Toolkit.getDefaultToolkit().getScreenResolution();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
ExitColor=Color.BLUE;
InfoColor=Color.BLUE;
MultiColor=Color.BLUE;
StartColor=Color.BLUE;
t = new Thread();
t.start();
//Main Menu Size and Set Visible'
//Loop check getScreenSize() if 1600x900 then BgPic becomes BgResizedUser (controlled by loop)
setFocusable(true);
BgPanel = loadBufferedImage("\\bggfx\\FrogGierStartScreengroundPanel_sd.png");
BgPic = loadBufferedImage("\\bggfx\\FrogGierStartScreenBackground.png");
GameBG = loadBufferedImage("\\bggfx\\map.png");
switch(screenRes)...
BgPanel = loadBufferedImage("/bggfx/FrogGierStartScreengroundPanel_sd.png");
rather than \\, it produces the same effect.
So what is wrong? It is not the images... They load perfectly in Eclipse! Maybe the code on lines 56-58 is wrong though? Looking for any suggestions!
And yes, I'm exporting all my resources into the JAR when I "EXPORT" it in Eclipse.
I can get it to run but only if I take away all images that use loadBufferImage...
Very strange.
Also audio does not play... Seems like it can't find the resources :|
Most Likely this is the culprit:
at javax.imageio.ImageIO.read(Unknown Source)