I want to play a .wav file using java code which is in a jar file as resource. My code is look like this -
try { URL defaultSound = getClass().getResou
Use Class.getResourceAsStream()
Once you have a handle to the inputStream, get the audioInputStream and do the rest.
InputStream is = getClass().getResourceAsStream("......"); AudioInputStream ais = AudioSystem.getAudioInputStream(is); Clip clip = AudioSystem.getClip(); clip.open(ais);