TheGamerPlayz TheGamerPlayz - 1 month ago 5
Java Question

BufferedImage not loading from png

I am trying to load an image from a spritesheet and its been a while since I've made a 2d game, so I think I probably forgot something important. I have

added to the class folder and have been trying for quite a while to load it with no success. I may have loaded it into the incorrectly buildpath, but I don't think so.
Here is the error:

Exception in thread "Thread-2" java.lang.IllegalArgumentException: input == null!
at Source)
at me.xthegamerplayz.Dodger.Dodger.init(
at Source)

And here is where I am loading the image

public static BufferedImage loadImage(String path){
try {
catch (IOException e) {
return null;

And finally this is where I am loading the images:

public static void init() {
sheet = new SpriteSheet(ImageLoader.loadImage("/res/entities/entitySprites.png"));

player = sheet.crop(0, 0, width, height);
enemy = sheet.crop(1, 0, width, height);

Does anyone see a reason why it is not loading?


It cannot find the resource. You can inspect the jar as it is in zip format. Most likely the path starts wrong. It also is case-sensitive.

sheet = new SpriteSheet(ImageLoader.loadImage("/entities/entitySprites.png"));