I'm trying to prank my friends with the semester's final Java program. It's a version of Space Invaders, and I added some annoying mp3 sounds to play after the game closes. I used Javazoom to play the mp3, and everything worked before exporting the project.
I learned resource files needed to be kept in a resources folder, which I have made. mp3 files and png files were placed in the same folder, and using code like the following works fine to display the images.
Image bg = Toolkit.getDefaultToolkit().getImage(getClass().getResource("./resources/bg2.png"));
However, the mp3 player cannot seem to access the resources folder. The InputStream always comes back as null when using this code:
//where fileName = /C:/Users/myName/JavaF16/Personal/bin/SpaceInvaders/resources/6.mp3
InputStream is = SpaceInvaders.class.getResourceAsStream(fileName.toString());
Player playMP3 = new Player(is);
fileName is a valid location, I can paste it in my file explorer and the mp3 will play. I read in that it needed a / on the front, but using that had no effect. I will admit that I'm not sure the project's folders are arranged properly, our class never taught about build paths or even source folders. But I did add all the resources to the build path. Here's a snapshot of the folder arrangement.
If I look at the exported jar in winRAR, all of the resources are included.
Any help would be much appreciated, thank you.