I’m having some trouble exporting my project to a .jar file. I have a res folder where assets are stored and its been added to the build path. I’ve exported the project and made sure the res file is checked, but when I run it I get an IllegalArgumentException: input == null error. When I open the .jar file in 7zip I see all my assets in the root of the file and the res folder isn’t there.
This is my code for loading assets.
private String path;
private String name;
public final int SIZE;
public int[] pixels;
public static SpriteSheet textures = new SpriteSheet("/textures.png", "textures", 512);
public static SpriteSheet font = new SpriteSheet("/font.png", "font", 256);
public static SpriteSheet gui = new SpriteSheet("/gui.png", "gui", 256);
public SpriteSheet(String path, String name, int size){
this.path = path;
this.name = name;
this.SIZE = size;
pixels = new int[size * size];
load();
}
private void load(){
try{
BufferedImage image = ImageIO.read(SpriteSheet.class.getResource(path));
int w = image.getWidth();
int h = image.getHeight();
image.getRGB(0, 0, w, h, pixels, 0, w);
}catch(IOException e){
System.err.println("Error: Could not load texture " + name + " @ " + path);
e.printStackTrace();
}
}
[SOLVED]
For some reason the file extension for gui.png was gui.PNG in eclipse, when I ran the program in eclipse it could locate the file fine, but when it tried to find it in the jar it had no idea.