I have a program in Java using LWJGL. It runs fine in Eclipse, but when I try to compile it as a jar file it crashes, giving me a NullPointerException. It's been asked before, I know, but I don't seem to get an answer that works. Any help here? Thanks in advance!
The thing that seems to be having the problem is the class TextureHelper:
public class TextureHelper {
public static Texture LoadTexture(String texture)
{
try {
return TextureLoader.getTexture("PNG", ResPlaceholder.class.getResourceAsStream(texture));
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
Some notes:
I've also tried "/res/" + texture, as well as many other things like it.
ResPlaceholder is a class that sits in the res folder where I store all my images. It's a blank empty class.
This works perfectly in Eclipse.
My jar has these folders (just as an example):
foo.jar
----core
--------TextureLoader
----res
-------- Assorted Image Files
-------- ResPlaceholder
This is the same as the packages in eclipse.
Any help you have would be appreciated, I've been stuck on this for days with no progress.
EDIT:
META-INF/MANIFEST.MF
Main.class config/
config/Images.class
core/
core/LevelLoader.class
core/TextureHelper.class
core/TileSet.class
-Skipping some other stuff that has nothing to do with this-
res/
res/ResPlaceholder.class
res/BlankImg.png
res/test.txt
res/testImg.png
res/testTiles.png
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…