Link to home
Start Free TrialLog in
Avatar of luke032397
luke032397

asked on

java.lang.NullPointerException error

I am currently working on putting simple *.gif images on my java applet and
cannot get the picture to show up on the html document's applet frame.  The
same holds true with playing sounds  The luketest.html opens fine, the
applet compiles, but no sound is played.  The applets compile and the paths
are correct relative to both the html document and class file which are in
the same folder.  I will post both codes and note that the misc file in the
getCodeBase() instruction is in the same level of the same folder as the
html and class files.  I will paste the source for the html page and the
applet it contains for the playing sounds.  All that I get is the applet
frame with the words "playing sounds...".  Any help would be greatly
appreciated.  When using appletviewer to read luketest.html, as oppossed to
IE, I get the following message on the MS DOS screen:


java.lang.NullPointerException:
      at htmltest.run(htmltest.java:28)
     at java.lang.Thread.run(Thread.java:481)



<HTML>
<HEAD>
<TITLE>testjava</TITLE>
</HEAD>
<BODY>
<A NAME = "TOP"> </A>
<p>Below lies my java applet to be tested</p>
<Applet code="htmltest.class" width=250 height=180>
</Applet>
</BODY>
</HTML>




import java.awt.Graphics;
import java.applet.AudioClip;


public class htmltest extends java.applet.Applet
  implements Runnable {

  AudioClip sound;
     Thread runner;

  public void start() {
    if (runner == null) {
      runner = new Thread(this);
      runner.start();
    }
  }

  public void stop() {
    if (runner != null) {
      if (sound != null) sound.stop();
      runner.stop();
      runner = null;
    }
  }

  public void run() {
   
    sound.loop();
     
  }
   


  public void intit(){
    sound = getAudioClip(getCodeBase(), "misc/nilesong.au");
   
  }


  public void paint(Graphics g){
    g.drawString("Playing Sounds....", 10, 10);

  }

}



Thank You

Luke Danielson
ASKER CERTIFIED SOLUTION
Avatar of jrsp
jrsp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial