Java Applets

27 Oct 2010

Hi All

I have been playing with the HTTP server and Michael Walkers fine work on interfacing with Java.
That demo works fine on my mbed!

I have an applet built with Eclipse packaged into a jar file.
I can serve the web page from my MBED but get errors when trying to run the applet.

load: class SolarMonitor not found.
java.lang.ClassNotFoundException: SolarMonitor
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://192.168.1.65/SolarMonitor.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 9 more
Exception: java.lang.ClassNotFoundException: SolarMonitor

 

No I'm no expert, but it looks like the browser can't find my applet, the jar file is present and as far as i can tell, it does contain my applet.

The web page is super simple:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Solar Monitor</title>
</head>

<body>

<h1>Solar Monitor</h1>
<P align = "CENTER">
<APPLET ARCHIVE="Solar.jar" code="SolarMonitor.class" WIDTH="700" HEIGHT="410">
<PARAM NAME="rate"    VALUE="1000">
The Applet should be here, check it has been loaded on to mbed and that Java is installed and enabled in your browser.
</APPLET>
</P>
</body>
</html>

This is a tweaker version of Michaels example.

I assume it's a class path issue or simmilar, complicated by the server being on the mbed.

Any suggestions greatfully received.

Brendan

01 Nov 2010

Update:

As is often the way with these issues, looking for a complex error only to find a (fairly) simple solution.

The mbed file system uses 8.3 file naming convention.

so HelloWorld.class or mysimpleapplet.jar will not work as the http server will not be able to locate the files as they breach the 8.3 name rules.

hello.jar works fine.

Thanks to Michael for poniting out the obvious (to him).

29 Dec 2010

Hi,

I have the same problem:

<HTML> <TITLE> HTML Test Page </TITLE> <BODY> ftweb will appear below in a Java enabled browser.<BR> <APPLET CODEBASE = "" CODE = "ftweb.cls" NAME = "TestApplet" WIDTH = 400 HEIGHT = 300 HSPACE = 0 VSPACE = 0 ALIGN = Middle

<PARAM NAME="hostname" VALUE="192.168.1.126"> <PARAM NAME="portnumber" VALUE="5000"> </APPLET> </BODY> </HTML>

The httpServer mount point is "/files". I've put the class file in the same (root) directory as the .htm file but I get this error:

load: class ftweb.cls not found. java.lang.ClassNotFoundException: ftweb.cls at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.io.IOException: open HTTP connection failed:http://192.168.1.126/files/ftweb/cls.class at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) ... 9 more Exception: java.lang.ClassNotFoundException: ftweb.cls

It suggests that the browser requests the file cls.class instead of ftweb.cls! What can I do?

Ad