【发布时间】:2010-11-19 05:47:27
【问题描述】:
我有点卡住了。为什么这行不通?我只是收到一条错误消息:
java.lang.NoSuchMethodError: main
线程“main”中的异常
import java.awt.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class ShowPNG extends JFrame
{
public void main(String arg)
{
if (arg == null ) {
arg = "C:/Eclipse/workspace/ShowPNG/bin/a.png";
}
JPanel panel = new JPanel();
panel.setSize(500,640);
panel.setBackground(Color.CYAN);
ImageIcon icon = new ImageIcon(arg);
JLabel label = new JLabel();
label.setIcon(icon);
panel.add(label);
this.getContentPane().add(panel);
this.setVisible(true);
}
}
【问题讨论】:
-
s/public void main(String arg)/public static void main(String [] arg)