I have a problem with my application. When I run the application in Eclipse, the sound played well, but if I export the application to a runnable jar, the sound will not work.
The method in which the sound is played:
public static synchronized void playSound()
{
new Thread(new Runnable()
{
public void run()
{
try
{
Clip clip = AudioSystem.getClip();
AudioInputStream inputStream = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("sound.wav"));
clip = AudioSystem.getClip();
clip.open(inputStream);
clip.start();
}
catch (Exception e)
{
System.err.println(e.getMessage());
}
}
}).start();
}
Where is the mistake?
Sk1x1 source
share