类型:转载 责任编辑:asp.net 日期:2007/05/23
热门软件下载:
import java.applet.Applet;
import java.awt.*;
public class welcomeapplet extends Applet
{
Label textLabel;
public void init()
{
textLabel=new Label("welcome to world of java!");
textLabel.setAlignment(Label.CENTER);
this.add(textLabel);
}
}
写了一个基本的applet,在jdk下javac编译通过,但是用java执行时,出错:
Exception in thread "main" java.lang.NosuchMethod Error:main.
网友回答:
用java命令执行,没有main()方法呀,
要不然就嵌入到网页中执行。
建一个文本文件,把下面的代码粘进去,把txt改为html
<applet code="welcomeapplet.class" width=300 height=300>
</applet>
applet要嵌入网页中才能看到!
<html>
<applet code ="welcomeapplet.class" width="200" height = "200"></applet>
</html>
写一个这样的html文件和你的类文件放在一个路径下面然后用打开这个网页就可以了!