日期:2014-05-17  浏览次数:20761 次

Applet程序通过html页面传递参数的错误问题
java程序:
public class Applet1 extends Applet {
int a,b,c;
Label x;

public void init(){
a=Integer.parseInt(getParameter("i1"));
b=Integer.parseInt(getParameter("i2"));
c=a+b;
x=new Label("a="+a+",b="+b+",c="+c);
add(x);
}
}

html内容:
<html>
<head>
<title>sum</title>
</head>
<body>
<applet code=Applet1.class width="800" height="300">
<param name="i1" value=3/>
<param name="i2" value=5/>
</applet>
</body>
</html>





错误提示:
Java Plug-in 1.6.0_18
使用 JRE 版本 1.6.0_18-b07 Java HotSpot(TM) Client VM
用户主目录 = C:\Documents and Settings\Administrator
----------------------------------------------------
c: 清除控制台窗口
f: 终结在结束队列上的对象
g: 垃圾收集
h: 显示此帮助消息
l: 转储类载入程序列表
m: 打印内存使用
o: 触发日志记录
q: 隐藏控制台
r: 重新载入策略配置
s: 转储系统和部署属性
t: 转储线程列表
v: 转储线程堆栈
x: 清除类载入程序高速缓存
0-5: 设置跟踪级别为<n>
----------------------------------------------------


java.lang.NoClassDefFoundError: Applet1 (wrong name: text15/Applet1)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.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)
异常:java.lang.NoClassDefFoundError: Applet1 (wrong name: text15/Applet1)
载入:找不到类 Applet1.class。
java.lang.ClassNotFoundException: Applet1.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.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.FileNotFoundException: D:\workspace\testText\src\text15\Applet1\class.class (系统找不到指定的路径。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
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)
... 7 more
异常:java.lang.ClassNotFoundExcept