Created a ResourceLoader class to get the path to the images:

 public class ResourceLoader { static ResourceLoader rl = new ResourceLoader(); public static Image getImage(String fileName){ return Toolkit.getDefaultToolkit().getImage(rl.getClass().getResource("images/" + fileName)); } } 

How do you get the same path for wav files from the sounds folder?

  • one
    Is the option to change "images/" to "sounds/" not suitable? - Streletz
  • What are you going to play then the sound? - zRrr

1 answer 1

OK, I will describe

 URL resource = Object.class.getResource("/sounds/".concat(NAMESOUNDS)); try { BufferedInputStream sounds = new BufferedInputStream((InputStream) resource.openStream()); //ОТКРЫВАЕМ БУФЕРЕЗИРОВАННЫЙ ПОТОК } catch (IOException ex) { ex.printStackTrace(); } 

And then I do not know where you will use open wav in RAM. The answer is one do something based on Clip.

And PS all that is in the jar is not a directory for you; you will not look at the files that are in the sounds in the jar; you do in this directory the class class that returns links to you.