Simple Java Applet not loading in FireFox / Safari on MacOS

Posted by Sleepless on Stack Overflow See other posts from Stack Overflow or by Sleepless
Published on 2010-05-07T16:48:14Z Indexed on 2010/05/07 16:58 UTC
Read the original article Hit count: 313

Filed under:
|

Hello all,

I'm probably missing something very basic here. I'm trying to get my first applet to run inside a local HTML page in Firefox 3.6 on Mac OS 10.5.8. Here's the applet's code:

package SimpleApplet;

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

public class MyApplet extends Applet {

private static final long serialVersionUID = 1L;

public void init()
{
}

public void stop()
{
}

public void paint(Graphics g)
{
g.drawString("Tweedle-Dee!",20,40);
} 

}

Here's the HTML page:

<html>
<body>
Here's the applet: <br/>
<applet code="MyApplet.class" width="300" height="150">
</applet>
</body>
</html>

Both files (.class and .html) are in the same folder on my local machine. Now when I load the .html file into Firefox, a rectangle with a red X gets displayed. The applet works when started from Eclipse (using JRE 1.5 BTW).

Also, it's not a general problem with my browser, as several pages with applets (e.g. http://java.sun.com/applets/jdk/1.4/demo/applets/Blink/example1.html) work.

This is also difficult to troubleshoot because there is no output at all on the Java console...

Any suggestions are appreciated!

© Stack Overflow or respective owner

Related posts about java

Related posts about applet