Topic: Exception in thread "main" java.lang.NoSuchMethodError: main 方面的小问题,谢谢!

  Print this page

1.Exception in thread "main" java.lang.NoSuchMethodError: main 方面的小问题,谢谢! Copy to clipboard
Posted by: astronaut1
Posted on: 2006-01-11 14:52

我是一个新手,刚学没多久,遇到一个小问题,请各位帮忙,我编写了一个小程序

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

public class Menutest extends JApplet
{

public void init()
{ JMenuBar mb = new JMenuBar();
JMenu fileMenu = new JMenu("显示");
JMenu pullRightMenu = new JMenu("问好");
fileMenu.add("欢迎");
fileMenu.addSeparator();
fileMenu.add(pullRightMenu);
fileMenu.add("退出");
pullRightMenu.add(new JCheckBoxMenuItem("早上好!"));
pullRightMenu.add(new JCheckBoxMenuItem("下午好!"));
pullRightMenu.add(new JCheckBoxMenuItem("晚安!再见!"));
mb.add(fileMenu);
setJMenuBar(mb);
}
}

javac Menutest.java --->生成了Menutest.class文件
java Menutest --->会提示如下错误Exception in thread "main" java.lang.NoSuchMethodError: main

我知道是main方法的事,可是不知道如何可以执行成功
我的jdk安装在D:\Program Files\Java\jdk1.5.0
classpath=.;D:\Program Files\Java\jdk1.5.0\lib;D:\Program Files\Java\jdk1.5.0\lib\tools.jar;D:\Program Files\Java\jdk1.5.0\lib\dt.jar;
path=D:\Program Files\Java\jdk1.5.0\bin

2.Re:小问题,请大家帮忙~先谢了! [Re: astronaut1] Copy to clipboard
Posted by: neil99
Posted on: 2006-01-11 15:06

java 小程序
不用java来运行的
appletviewer ??

3.Re:小问题,请大家帮忙~先谢了!--NoSuchMethodError: main [Re: astronaut1] Copy to clipboard
Posted by: xuwensheng
Posted on: 2006-01-11 19:39

嵌入进html文件的<applet></applet>标签试试?

4.谢谢~ [Re: astronaut1] Copy to clipboard
Posted by: astronaut1
Posted on: 2006-01-11 20:16

谢谢各位的帮助,但问题还是不知道怎么解决.一个菜鸟问题请大家见谅.请哪位仁兄可以说下具体步骤

5.RE [Re: astronaut1] Copy to clipboard
Posted by: huaixiangdong
Posted on: 2006-01-12 12:26

Firstly, you need compile your Menutest.java, thus creat a class file in current directory.

Then create a simple html (test.html) file in the same directory as below:
"
<html>
<applet code=Menutest.class width=400 height=300>
</applet>
</html>
"
Finally, in your dos command window type:
appletviewer test.html

See that?

6.Thank you very much!!! [Re: astronaut1] Copy to clipboard
Posted by: astronaut1
Posted on: 2006-01-13 09:26

Thank you very much!!!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923