Problems with Applets
Hello!I try to write/learn about applet with Suns tutorial.
But I cant get the Simple.java (applet) at sun to work in my browser.
But it work with appletviewer.
The Simple.class and the simple.html file is in the same map.
The In the JavaKonsole in IE I get this message:
Error loading class: Simple
java.lang.NoClassDefFoundError
java.lang.ClassNotFoundException: Simple
at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
at com/ms/applet/AppletPanel.securedClassLoad (AppletPanel.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
at com/ms/applet/AppletPanel.run (AppletPanel.java)
at java/lang/Thread.run (Thread.java)
The simple.html file looks like this:
<HTML>
<HEAD>
</HEAD>
<BODY>
<APPLET CODE="Simple.class" codebase="C:\fredrik\javalabb" WIDTH=500 HEIGHT=20>
</APPLET>
</BODY>
</HTML>
I had tried both with and without codebase, relative and absolute.
And the Simple.java looks like this:
/*
* 1.1 version.
*/
import java.applet.Applet;
import java.awt.Graphics;
public class Simple extends Applet {
StringBuffer buffer;
public void init() {
buffer = new StringBuffer();
addItem("initializing... ");
}
public void start() {
addItem("starting... ");
}
public void stop() {
addItem("stopping... ");
}
public void destroy() {
addItem("preparing for unloading...");
}
void addItem(String newWord) {
System.out.println(newWord);
buffer.append(newWord);
repaint();
}
public void paint(Graphics g) {
//Draw a Rectangle around the applet's display area.
g.drawRect(0, 0,
getSize().width - 1,
getSize().height - 1);
//Draw the current string inside the rectangle.
g.drawString(buffer.toString(), 5, 15);
}
}
But when I try it online at suns site with IE at: http://java.sun.com/docs/books/tutorial/applet/overview/lifeCycle.html
...it works.
MY IE is version 6.0.2...
