我这个程序为什么编译成功,运行不了????
程序如下用JCREATOR编译成功,运行时却提示“
Exception in thread "main"
java.lang.NoSuchMethodError: main”错误,哪位大虾来修改解释一下?谢谢!!
import java.net.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.*;
public class liaotian extends JFrame {
JPanel contentPane;
Label label1=new Label();
Label label2=new Label();
Label label3=new Label();
Label label4=new Label();
TextField textField1=new TextField();
TextField textField2=new TextField();
TextField textField3=new TextField();
TextField textField4=new TextField();
Button button1=new Button();
Button button2=new Button();
TextArea textArea1= new TextArea();
boolean online = false;
int portIn = 5000;
int portOut=5001;
DatagramPacket sendpacket,receivepacket;
DatagramSocket sendsocket,receivesocket;
public liaotian(){}
private void toInit()throws Exception {
contentPane=(JPanel)this.getContentPane();
label1.setText("发送");
label1.setBounds(new Rectangle(13,100,60,21));
contentPane.setLayout(null);
this.setSize(new Dimension(363,320));
this.setTitle("聊天");
label2.setText("朋友IP");
label2.setBounds(new Rectangle(12,19,109,23));
label3.setText("接收端口");
label3.setBounds(new Rectangle(12,58,55,22));
label4.setText("发送端口");
label4.setBounds(new Rectangle(180,58,55,22));
textField3.setText("5000");
textField4.setText("5001");
textField2.setText("210.77.26.60");
button1.setLabel("发送");
button1.setBounds(new Rectangle(280,100,59,21));
button1.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(ActionEvent e){
button1_actionPerformed(e);}});
button2.setLabel("连接");
button2.setBounds(new Rectangle(280,20,59,21));
button2.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(ActionEvent e){
button2_actionPerformed(e);}});
textField4.setBounds(new Rectangle(240,58,90,22));
textField3.setBounds(new Rectangle(70,58,90,22));
textField2.setBounds(new Rectangle(123,20,120,19));
textField1.setBounds(new Rectangle(76,100,190,19));
textArea1.setBounds(new Rectangle(11,140,333,134));
textArea1.setEditable(false);
contentPane.add(label4,null);
contentPane.add(label3,null);
contentPane.add(label2,null);
contentPane.add(label1,null);
contentPane.add(textField1,null);
contentPane.add(textField2,null);
contentPane.add(textField3,null);
contentPane.add(textField4,null);
contentPane.add(textArea1,null);
contentPane.add(button1,null);
contentPane.add(button2,null);
try{
sendsocket=new DatagramSocket(5001);
receivesocket=new DatagramSocket(5000);
}
catch(
SocketException se){
se.printStackTrace();
System.exit(0);
}
}
protected void processWindowEvent(WindowEvent e) {}
public void waitforpackets() {
while(true){
try{
byte[]array=new byte[100];
receivepacket=new DatagramPacket(array,array.length);
receivesocket.receive(receivepacket);
textArea1.append("\n from"+receivepacket.getAddress()
+":"+receivepacket.getPort()+"get:");
byte data[]=receivepacket.getData();
String received=new String(data,0);
t