I am making a 2d game based on minecraft. The code below worked on my pc but not my mac. The image I am trying to load is in the Background folder inside the Resources folder. Other posts I have read suggest the error is because my image couldn't be found but I don't know what else to put for the image location.
here is my code:
public MenuState(GameStateManager gsm) {
super(gsm);
try {
// load minecraft Background
minecraft = ImageIO.read(
getClass().getResourceAsStream("/Backgrounds/minecraft.png ")
).getSubimage(0, 300, 400, 300);
// load floating head
head = ImageIO.read(
getClass().getResourceAsStream("/HUD/Hud.gif")
).getSubimage(0, 12, 12, 11);
Error Message:
java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(ImageIO.java:1348)
at GameState.MenuState.<init>(MenuState.java:50)
at GameState.GameStateManager.loadState(GameStateManager.java:40)
at GameState.GameStateManager.<init>(GameStateManager.java:34)
at Creeper.GamePanel.init(GamePanel.java:71)
at Creeper.GamePanel.run(GamePanel.java:76)
at java.lang.Thread.run(Thread.java:745)
Thanks for the help!