-
I need help with Applets
Trying to learn how to use applets, i hope this is the correct place to post! If it is not please direct me to the correct place and I will post there (and delete this one if i can)
where to begin....
When i try to open up the website i get this error in the java console:
load: class HelloWorldApplet.class not found.
java.lang.ClassNotFoundException: HelloWorldApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed: url
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unk nown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(U nknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknow n Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: HelloWorldApplet.class
load: class HelloWorldApplet not found.
java.lang.ClassNotFoundException: HelloWorldApplet
at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:url
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unk nown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(U nknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknow n Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: HelloWorldApplet
I have this code in my .php file:
Code:
<applet archive = "HelloWorld.jar"
code= HelloWorldApplet
width="98%"
height="900"
alt="ATVe is not working on your system (requires at least Sun Java 1.5)!">
</applet>
in the directory i have:
index.php (which contains my applet code and some titles etc.) and HelloWorld.jar which contains:
jar tf HelloWorld.jar
META-INF/
META-INF/MANIFEST.MF
HelloWorld/
HelloWorld/.DS_Store
HelloWorld/HelloWorldApplet$1.class
HelloWorld/HelloWorldApplet.class
I am a little suspicious about that $1.class....but i do not know that much about java (it got created because of an annonymous inner class? probably something to do with using GUI or JApplet)
my HelloWorldApplet class looks like this:
Code:
package HelloWorld;
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;
public class HelloWorldApplet extends JApplet {
//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");
}
}
}
SORRY for the ridiculously long post i just wanted to be thorough....
I do not know why this is not working...can anyone help me out?
-
Wow i got it
I changed code=HelloWorldApplet
to
code = HelloWorld.HelloWorldApplet
argh..
EDIT:
well actually it works when i use my windows machine (which has java JDK 6) but it does not work when i use my MAC.....
eh?? please help