Hello, this is my first time here and I am in need of dire help. This is my first time coding in java and it has been nothing but a pain thus far. I can run a simple console app, but for some reason, the knowledge of how to run an applet is far beyond me. Two days I have been searching the internet endlessly for some ray of hope, but nothing... Can someone please tell me what I am doing wrong?
I have the latest versions of both Eclipse and Java on my system. The applet will load find inside Eclipse but fails when it comes to the browser.
My Class:
package helloWorld;
import java.applet.Applet;
import java.awt.*;
public class HelloWorldApplet extends Applet {
/**
*
*/
private static final long serialVersionUID = 1L;
public void paint(Graphics g){
g.drawString("Hello World!", 20, 30);
this.setBackground(Color.blue);
}
}
Html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<applet code="HelloWorld.bin.helloWorld.HelloWorldApplet" width="400" height="200"></applet>
</body>
</html>
Java Console Error:
Java Plug-in 1.6.0_05
Using JRE version 1.6.0_05 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator
----------------------------------------------------
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
p: reload proxy configuration
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>
----------------------------------------------------
java.lang.NoClassDefFoundError: HelloWorld/bin/helloWorld/HelloWorldApplet (wrong name: helloWorld/HelloWorldApplet)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)