Hey guys!
I’m currently trying to export my game into a single jar file. I used JarSplice to create a Fat Jar.
My Game loads the Spritesheet as a Slick2D Texture in a static variable.
At first I tried to load the Texture like this:
public static Texture loadTexture(String path) {
try {
return TextureLoader.getTexture("PNG",new FileInputStream(path));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
This worked in Eclipse, but not exported as a jar. I googled for a while and changed it to:
public static Texture loadTexture(String path) {
try {
return TextureLoader.getTexture("PNG",MyTextureLoader.class.getResourceAsStream(path));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
Now the Game won’t even work in eclipse and I get a “Exception in thread “main” java.lang.ExceptionInInitializerError” when I try to run the game. More precisely when I try to bind the texture.
Could anyone help me?