I have created a simple GUI that loops a .wav-file when a button is clicked. This works perfectly when run in Eclipse. However, when compiling it in a runnable .jar, it does not run. No errors thrown, it just doesn't run. Here is the full code:
import java.awt.EventQueue; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.UnsupportedAudioFileException; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.io.File; import java.io.IOException; public class Lydtest extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JPanel contentPane; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Lydtest frame = new Lydtest(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. * @throws IOException * @throws UnsupportedAudioFileException * @throws LineUnavailableException */ public Lydtest() throws UnsupportedAudioFileException, IOException, LineUnavailableException { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 114, 72); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); File lydklipp = new File("pessent.wav"); AudioInputStream audioIn = AudioSystem.getAudioInputStream(lydklipp); final Clip clip = AudioSystem.getClip(); clip.open(audioIn); JButton btnTestLyd = new JButton("Pezzent!"); btnTestLyd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { clip.loop(getDefaultCloseOperation()); } }); btnTestLyd.setBounds(10, 11, 91, 23); contentPane.add(btnTestLyd); } }