我的java不能运行了,提示Could not find the main class怎么弄啊?

可以编译 但运行的时候就不行了
import javax.swing.*;
import java.awt.GridLayout;
@SuppressWarnings("serial")
class AFrame extends JFrame {
GridLayout gridLayout;
JButton a[]=new JButton[15];

AFrame(String s){
super(s);
setSize(500,300);
setLocationRelativeTo(null);

JPanel contentPane=new JPanel();
setContentPane(contentPane);
gridLayout=new GridLayout(3,5);
contentPane.setLayout(gridLayout);

for (int i=0;i<9;i++){
a[i]=new JButton(i+"");
}
a[9]=new JButton("加上"+"");
a[10]=new JButton("减去"+"");
a[11]=new JButton("乘以"+"");
a[12]=new JButton("除以"+"");
a[13]=new JButton("="+"");
a[14]=new JButton("无"+"");
for (int j=0;j<15;j++){
contentPane.add(a[j]);
}
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}
public class Jisuanqi {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
AFrame frm=new AFrame("计算器");
}
}

你是否用的Eclipse类似的IDE那,这应该是你的这个文件不属于这个project造成的,把文件重新导一遍试试吧
温馨提示:内容为网友见解,仅供参考
第1个回答  2010-01-06
提示的错误是没有main()方法,JAVA要求文件名和类名一致,你现在的main()方法在Jisuanqi类中,看看你的文件名是什么。。。
第2个回答  2010-01-06
没有main方法。
第3个回答  2010-01-06
要编译后,看看在说。
第4个回答  2010-01-06
这是没有主函数的意思吧?
相似回答