hi friends,
i am a beginner in java.i am working on a program to play a sound file.
i used the following code snippet.
the program is compiling successfully.i am getting the following run time errors.import java.applet.*; import java.awt.event.*; import java.awt.*; class SoundExample extends Applet { AudioClip soundFile1; SoundExample() { soundFile1=getAudioClip(getDocumentBase(),"1.au"); soundFile1.play(); } } public class sound_eg { public static void main(String args[]) { SoundExample s=new SoundExample(); System.out.println("Completed"); } }
"Exception in thread "main" java.lang.NullPointerException
at java.applet.Applet.getDocumentBase(Applet.java:141 )
at SoundExample.(init)(sound_eg.java:10)
at sound_eg.main(sound_eg.java:18)
i even tried by using a function "init" instead of a constructor.
kindly help me!!![/COLOR]