Cannot play wav sounds in java

I have a simple program that will play the wav files when executed. But the sound doesnt play. Here is the code

import javax.swing.*;

import java.awt.*;

import java.net.*;

import java.beans.*;

import java.io.*;

import java.applet.*;

import java.awt.event.*;

publicclass testextends JPanel

{

publicstaticvoid main(String args [])

{

try{

URL dance =new URL("file:res/hallelujah.wav");

AudioClip danceClip = Applet.newAudioClip(dance);

danceClip.play();

}catch (Exception e)

{

e.printStackTrace();

}

}

Can anyone the error? Thanks

[1421 byte] By [Hanz_05a] at [2007-11-27 11:19:19]
# 1

the code continues after 'danceClip.play();' and exits.

simple answer (not the best way) is to add a pause

danceClip.play();

Thread.sleep(3000);//or whatever

Michael_Dunna at 2007-7-29 14:36:03 > top of Java-index,Desktop,Core GUI APIs...