(I’ve attempted to put the tl;dr stuff in bold)
Hey everyone, I’m totally new here and relatively new to Java, I was hoping I could get some help regarding a practice game I’m making.
I did a few searches, I didn’t find anything like this, but I also wasn’t going to spend my entire evening tunneling through forum searches XD
Anyway, my game was working fine when I ran it in Eclipse, but I wanted to be able to show it to my buddies, I exported it as an executable Jar and ran it.
Nothing ran at all. So I looked into it and apparently my images aren’t loading up properly when I run the Jar.
Why is it that Eclipse can find my images and run the thing fine and when I export it nothing works?
I’m assuming it’s to do with where I placed my files. I HAVE NO IDEA WHERE TO PUT THEM! But I do want them in an images folder at the very least.
I’ve currently got them in “src/platformer/images”
Platformer is my package name/folder and has all my code in there.
The code I’m using to load the images up has changed a few times, but what I’m currently using is:
BufferedImage blockTileset = ImageIO.read(this.getClass().getResource(“images/tiles.png”));
Now I’m not entirely sure what I’m doing there, I just read from Kev Glass’ tutorials that it’s a good idea to do it that way.
Can anyone lend some insight into this? Do I need to move my images folder somewhere? Do I need to add a slash or something to my file path? I’ve spent all day on this annoying problem and haven’t got anywhere! I know it’s a simple, stupid problem, but please bear with me!
Thanks in advance
P.S. You may need to dumb down your answers a little bit, I’m not a full on programmer yet! So many things I’ve looked up today where people had problems that were solved thusly, ‘Simply do this! insert a whole mess of uncommented code with poorly named variables’ ‘Wow thanks for solving my problem! :D’. Then you have me sitting here, thinking in angry scribbles and reaching for another coffee…