So I've been making a sort of LoZ spinoff game using Slick2D to get better with Java, and I figured I'd figure out now how to export it so I can test it on different machines.
The issue I'm hitting right now is that once I've exported my whole project, nothing happens once I double click the created. What I mean is that the screen size, position and everything is correct, but instead of any graphic showing, it's just a white screen. I've tried doing a few of the answers here, such as using the Fat-Jar Exporter, and they haven't worked.
Could it be because I'm not using the correct settings and such? The code I'm using to import my pictures into my Tile class is this:
public static BufferedImage background, terrain, items, characters;
public Tile()
{
try {
/*Tile.background = ImageIO.read(getClass().getResource("res/bg.png"));*/
Tile.background = ImageIO.read(Tile.class.getResourceAsStream("/bg.png"));
//Tile.terrain = ImageIO.read(new File("res/terrain.png"));
Tile.characters = ImageIO.read(Tile.class.getResourceAsStream("/characters.png"));
//Tile.items = ImageIO.read(new File("res/items.png"));
} catch (IOException e) {
System.out.println("Error Loading Images");
}
}
The commented out bits in the code are things I've tried before, excluding the Tile.terrain and Tile.background ones. I've got a res folder that I've included in the project's properties as a source folder on the build path. That res folder has a few subfolders (World, GUI, and Sound) and a few files inside of it (bg.png, characters.png). Here's how the res folder looks as a file path from Windows Explorer: C:\WorkArea\Java2D\res
Does anyone have any idea of what to do?
UPDATE #1
So after following your advice, JB Nizet, the following error comes up in my Command Prompt after running the jar:
Exception in thread "main" java.lang.NoClassDefFoundError: org/newdawn/slick/SlickException
at org.rc.Core.start(Core.java:89)
at org.rc.Core.main(Core.java:81)
Cause by: java.lang.ClassNotFoundException: org.newdawn.slick.SlickException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPriveliged(Native Method)
at java.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadCLass(Unknown Source)
at java.lang.ClassLoader.loadClass(unknown Source)
... 2 more
UPDATE #2
So I've figured out how to package Slick and what-not together (I used JarSplice to piece them all together), and now I'm getting a resource related error:
Exception in thread "main" java.lang.RuntimeException: Resource not found: res/World/Level_1.tmx
at org.newdawn.slick.util.ResourceLoader.getResourcAsStream(ResourceLoader.java:69)
at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:106)
at org.rc.Level<init>(Level.java:32)
at org.rc.Core.start(Core.java:89)
at org.rc.Core.main(Core.java:81)
This tells me that I'm not bring in my resources correctly, even though, in my project viewer in Eclipse, my res folder is a source folder on the build path.
Does anyone know what to do?
My Answer
So I decided to bring the project over to NetBeans amnd once there it worked. For anyone with the problems I described, try that.
My this helps. ^^