import java.applet.AudioClip; import java.net.URL; public class MyApplet { // sound clip to make a frog ribbet croaking sound private AudioClip frog; /** * Get the applet started. */ public void init() { // You must initialise frog in init, not the usual static or instance initialiser, // ribbet.au is a sound file in the jar under the same package as the Applet // The file must be an au, wav, midi or aiff. // BEWARE getResource only works in Applets signed with a real certificate. URL u = MyApplet.class.getResource( "ribbet.au" ); if ( u == null ) { throw new IllegalArgumentException ( "ribbet.au missing from the jar" ); } if ( DEBUGGING ) { // see where Java is getting your resource out.println( u ); } frog = getAudioClip( u ); ... } ... public void croak() { // make the sound frog.play(); } }