title: Playing audio from jar file
body: <p>I have found plenty of threads on this subject but i still dont get it to work. It works easily from the compiler but not from the jar file. It seems the jar file finds the audio file but it just doest play it.</p>
  
  <pre><code>import sun.audio.*;
  import java.awt.event.*;
  import java.io.*;
  import javax.swing.*;
  
  @SuppressWarnings({"serial","restriction"})
  public class JarSoundTest1 extends JFrame { 
    JButton button;
    InputStream in;
    AudioStream as;
  
    public JarSoundTest1() throws Exception {
  
        JOptionPane.showMessageDialog(null, this.getClass().getResource("blopp.wav"));          
  
        button = new JButton("Click to Blopp!");
        button.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              try{
                  in = this.getClass().getResourceAsStream("blopp.wav");
                  as = new AudioStream (in);
                  AudioPlayer.player.start(as);
  
                  JOptionPane.showMessageDialog(null, "try");
  
              }catch(Exception ex){
  
                  ex.printStackTrace();
                  JOptionPane.showMessageDialog(null, "catch");               
              }
          }       
        });
        add(button);    
    }
  
    public static final void main(String[] args) throws Exception {
        JFrame frame = new JarSoundTest1();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(200, 200);
        frame.setVisible(true);     
    }  
  }
  </code></pre>
  
  <p>The JOptionPane displays "try" every time the button is clicked, indicating the file is found i assume? Still no sound is played. I have tried using audio files placed both inside and outside the jar file. Help to understand this is much appreciated.</p>