title: How to play a WAV in Java, when the WAV is contained inside the JAR
body: <p>I've been trying to deal with sound on my Applet for a bit now, and Instead of trying all the different methods, what is the best way to play Sound in Java? There are a few requirements:</p>
  
  <ul>
  <li>Needs to be able to loop</li>
  <li>Needs to be able to load a WAV from an archive JAR(I think with the getClass().getResource)</li>
  <li>Needs to be able to play more than one sound at the same time, and not clip already playing sounds</li>
  </ul>
  
  <p>Thanks you so much for looking at my question and I hope you guys have an answer!</p>
  
  <p>Thanks to the wonderful help I almost have it working with this:</p>
  
  <pre><code>public class MyGame() {
     Clip bullet;
  
  
      public void init(){
          try {
  
          bullet = AudioSystem.getClip();
          URL url2 = this.getClass().getResource("bulletSound.wav");
          AudioInputStream ais2 = AudioSystem.getAudioInputStream( url2 );
  
          bullet.open(ais2);
          } catch (LineUnavailableException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          } catch (UnsupportedAudioFileException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          }
      }
      randomMethodToPlayBullet(){
          bullet.setFramePosition(0);
          bullet.start();
      }
  }
  </code></pre>
  
  <p>The problem is that the bullet sound plays, but if the randomMethodToPlayBullet is called say twice in a row, before the first bullet sound is done, the seonc one doesnt play.</p>