Simple problem with Applet in HTML [message #778398] |
Thu, 12 January 2012 18:37 |
Chris Crawford Messages: 7 Registered: January 2012 |
Junior Member |
|
|
This is a such a simple problem that I'm shocked by my inability to solve it, but after five days of messing with it, scouring the web, re-reading tutorials, and searching previously-asked similar questions here, I still haven't figured it out. I'm going to present it in great detail to make sure that I've explained it completely.
1. Context: I'm using Eclipse Indigo Service Release 1 on a Mac with OS 10.7.2 with 8 GB RAM.
2. Here's the Java code:
package helloYellow;
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;
public class HelloWorld extends JApplet {
private static final long serialVersionUID=1L;
//Called when this applet is loaded into the browser.
public void init() {
//Execute a job on the event-dispatching thread; creating this applet's GUI.
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JLabel lbl = new JLabel("Hello World");
add(lbl);
}
});
} catch (Exception e) {
System.err.println("createGUI didn't complete successfully");
}
}
}
3. When I run this as an applet inside Eclipse, it works perfectly.
4. Here's the HTML page that calls the applet:
(I'm not permitted to use links until I have posted more than 5 messages, so I am replacing the HTML delimiters with curly braces)
{body}
Upper bracket text{br}
{applet code="hellowYellow/HelloWorld.class" width="300" height="150"}{/applet}{br}
Lower bracket text{br}
{/body}
{/html}
4. Apparently I'm not allowed to include images in my postings yet, so I'll describe the page as it appears in Safari: it shows shows "Upper bracket text" and "Lower bracket text". Between them is a box outline that says "Error. Click for details".
5. When I click on "Click for details", I get an error message stating that the application failed to run, presenting me with a button permitting me to "click for details". When I click that button, I get a Java Console window with the following contents:
Java Plug-in 1.6.0_29
Using JRE version 1.6.0_29-b11-402-11M3527 Java HotSpot(TM) 64-Bit Server VM
User home directory = /Users/chris
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
load: class hellowYellow/HelloWorld.class not found.
java.lang.ClassNotFoundException: hellowYellow.HelloWorld.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:252)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:249)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:179)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:690)
at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3045)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1497)
at java.lang.Thread.run(Thread.java:680)
Exception: java.lang.ClassNotFoundException: hellowYellow.HelloWorld.class
load: class hellowYellow/HelloWorld.class not found.
java.lang.ClassNotFoundException: hellowYellow.HelloWorld.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:252)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:249)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:179)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:690)
at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3045)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1497)
at java.lang.Thread.run(Thread.java:680)
Exception: java.lang.ClassNotFoundException: hellowYellow.HelloWorld.class
6. Here is the folder containing the HTML page has these contents:
HelloWorld.class
HelloWord$1.class
helloYellow:
...HelloWorld.class
...HelloWord$1.class
java.policy.applet
Java2.html
Note that I used some overkill in including the class files twice: once by themselves and once inside the folder "helloYellow". I just wanted to make absolutely certain that they were accessible to the HTML file, no matter what assumptions it made as to their locations.
Can anybody figure out where I'm going wrong here?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03428 seconds