2

I've tried a number of applets out with my applet viewer and I keep getting the same response in the window, "Start: applet not Initialized". It doesn't matter how simple the program is, it compiles fine in Xcode, but it won't show up in the applet viewer nor in my browser. I've searched for answers to this problem, but it always turns out to be some error in the code of the questioner. I've tried many codes but none of them work. Here's the most simple example:

import java.awt.*;
import java.applet.*;

public class SimpleApplet extends Applet {
   public void paint(Graphics g) {
       g.drawString("A Simple Applet",20,20);    
    }
}

Here is the html:

<html>
<body>
    <applet code="SimpleApplet" width=200 height=60>
    </applet>
</body>
</html>

These are the error reports:

load: class SimpleApplet not found.
java.lang.ClassNotFoundException: SimpleApplet
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:210)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:144)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:695)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:723)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:652)
    at sun.applet.AppletPanel.run(AppletPanel.java:326)
    at java.lang.Thread.run(Thread.java:613)

What could be the problem?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189

1 Answers1

0

Actually problem with the url of code in applet code (code="SimpleApplet") just run applet from program itself. Try

import java.awt.*;
import java.applet.*;
/*<applet code="SimpleApplet" width=500 height=500 ></applet>*/
public class SimpleApplet extends Applet {
   public void paint(Graphics g) {
       g.drawString("A Simple Applet",20,20);    
    }
}
Shibin Raju Mathew
  • 920
  • 4
  • 18
  • 41