求助

04-10-09 newuser
刚好学java
测试applet出现了问题


问题如下以及相关信息描述如下:


源代码如下
-------- theApplet.html------------

<html>
<applet	code ="AdditionApplet.class" width=300 height=50>
</applet>
</html>
<p class="indent">


---------AdditionApplet.java-------------

import javax.swing.*;
import java.awt.Graphics;

public class AdditionApplet
{
	double sum;
	
	public void init()
	{
		String 	firstNumber,
			secondNumber;
		double 	number1,
			number2;

		//input two numbers
		firstNumber=
			JOptionPane.showInputDialog(
			"Enter the first floating-point value");
		secondNumber=
			JOptionPane.showInputDialog(
			"Enter the second floating-point value");

		number1=Double.parseDouble(firstNumber);
		number2=Double.parseDouble(secondNumber);
		//add the numbers
		sum= number1+ number2;
	}

	public void paint (Graphics g )
	{       
                  //output the result
		g.drawRect(15,10,270,20)	;
		g.drawString("the sum is "+sum ,25,25);  
	}
}
<p class="indent">


以上两个文件在同一目录下面
进入dos命令行,并进入相应目录
> javac AdditionApplet.java
> appletviewer theApplet.html

出现如下的错误
java.lang.ClassCastException
at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)
at sun.applet.AppletPanel.run(AppletPanel.java:298)
at java.lang.Thread.run(Thread.java:534)


使用的是win2k advance server 系统
jdk 用的是Java[TM] 2 Platform, Enterprise Edition 1.4 SDK 中的那个

环境变量
java_home D:\Sun\AppServer\jdk
classpath .\;%JAVA_HOME%\lib\tools.jar
path %JAVA_HOME%\bin(系统其他的就没写在这了)

请各位高手指点,感激不尽



newuser
2004-10-09 22:03
当我直接用IE打开那个html文件时候
不能正确运行
且状态栏上显示 :
load: class AdditionApplet not found

实在是冤枉啊 我明明将它们放在了同一个目录下面

请高手赐教 不胜感激


newuser
2004-10-11 18:54
高手们啊
行行好啊
为我指点迷津