I have problem with my app. When I run app in Eclipse, sound played well, but if I export app to runnable jar, sound doesn\'t work.
Method, where sound is played:
The problem is in this
AudioInputStream inputStream = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("sound.wav"));
in JAR file isn't working getResourceAsStream
for any reason. So I replace it with getResource
:
AudioInputStream inputStream = AudioSystem.getAudioInputStream(getClass().getResource("sound.wav"));
and this works fine.