I realize there's a million of these posts but none of them have helped me so here goes: I'm trying to deploy a very, very simple applet that will not load properly.
My HTML:
<html>
<head>
<meta http-equiv="Content-Type" content"text/html; charset=utf-8">
</head>
<body>
<applet code = "SimpleApplet.class"
width = "320" height = "100"></applet>
</body>
</html>
My Java:
package test;
import javax.swing.*;
public class SimpleApplet extends JApplet{
public void init(){
try{
SwingUtilities.invokeAndWait(new Runnable(){
public void run(){
JLabel lbl = new JLabel("Hello World");
add(lbl);
}
});
}
catch(Exception e){
System.out.println(e);
}
}
}
Both files are located in the same directory
/home/me/workspace/myProject/bin/test
If I run the applet on its own via Eclipse, it works fine. When I open the page I get the error
java.lang.NoClassDefFoundError: SimpleApplet (wrong name: test/SimpleApplet)
The error would suggest that I have incorrectly placed or named something. However, after trying
<applet code = "test/SimpleApplet.class"
width = "320" height = "100"></applet>
<applet code = "SimpleApplet.class"
codebase = "/test"
width = "320" height = "100"></applet>
along with other attempts, including removing the ", trying absolute and all partial path names, and using .java, it still does not work and I end up getting a ClassNotFoundException. Other answers point out that classpath and codebase (often relating to archive) issues are a primary reason for this occurring. However, I am not using a jar file and both files are in the same directory. Anyone know why this is occurring?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…