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:
1 2 3 4 5 6 7 8 9 10 11 12 13
| 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:
1 2 3 4 5 6 7 8 9 10 11 12 13
| 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?