首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

急这个警告是什么意思-The serializable class chatClient does not declare a static final ser

2012-01-31 
急,急:这个警告是什么意思--The serializable class chatClient does not declare a static final serialV

急,急:这个警告是什么意思--The serializable class chatClient does not declare a static final serialVersionUID field of
我是用一个eclipse来编一个client/server程序,为何在Client程序中出现上述这个警告  


我的Client   程序是
import   java.io.*;
import   java.net.*;
import   java.awt.*;
import   java.awt.event.*;

public   class   chatClient   extends   Frame   {

Socket   s   =   null;

DataOutputStream   dos   =   null;

TextField   texfid   =   new   TextField();

TextArea   taContent   =   new   TextArea();

public   void   launchFrame()   {
setLocation(300,   300);
this.setSize(400,   400);
add(texfid,   BorderLayout.SOUTH);
add(taContent,   BorderLayout.NORTH);
pack();
this.addWindowListener(new   WindowAdapter()   {
public   void   windowClosing(WindowEvent   e)   {
System.exit(0);
disconnect();

}

});
texfid.addActionListener(new   TFListener());
setVisible(true);
connect();
}

public   void   connect()   {
try   {
s   =   new   Socket( "127.0.1.1 ",   8888);
System.out.println( "connected ");
}   catch   (UnknownHostException   e)   {
e.printStackTrace();
}   catch   (IOException   e)   {
e.printStackTrace();
}

}

public   void   disconnect()   {
try   {
dos.close();
}   catch   (IOException   e)   {
e.printStackTrace();
}

}

private   class   TFListener   implements   ActionListener   {

public   void   actionPerformed(ActionEvent   e)   {
String   str   =   texfid.getText().trim();
taContent.setText(str);
texfid.setText( " ");
try   {
dos   =   new   DataOutputStream(s.getOutputStream());
dos.writeUTF(str);
dos.flush();
}   catch   (IOException   e1)   {
e1.printStackTrace();
}

}

}

public   static   void   main(String[]   args)   {
new   chatClient().launchFrame();
}

}


我的Server程序是:
import   java.net.*;
import   java.io.*;

class   chatServer2   {
boolean   bConnected=false;
DataInputStream   dis=null;

public   static   void   main(String[]   args)   {
new   chatServer2().start();
}
public   void   start(){
ServerSocket   ss=null;
try   {
      ss=new   ServerSocket(8888);
bConnected=true;
}catch(BindException   eb){
System.out.println( "port   in   use..... ");
System.out.println( "please   close   other   program   and   continue ");
}catch(IOException   ei){
ei.printStackTrace();
}
try   {
Socket   s   =   ss.accept();
client   c=new   client(s);
new   Thread(c).start();
}   catch   (IOException   e)   {
e.printStackTrace();
}finally{
try   {
ss.close();
}   catch   (IOException   e)   {


e.printStackTrace();
}
}
}
class   client   implements   Runnable{
private   Socket   s=   null;
private   DataInputStream   dis=null;
boolean   bConnected=false;

public   client(Socket   s){
this.s=s;
try   {
dis=new   DataInputStream(s.getInputStream());
}   catch   (IOException   e)   {
e.printStackTrace();
}
bConnected=true;

}
public   void   run()   {
try{
while(bConnected){
  dis=new   DataInputStream(s.getInputStream());
  String   str=dis.readUTF();
  System.out.println(str);
}
}catch(SocketException   ee){
System.out.println( "the   client   is   over! ");
}catch   (IOException   e){
e.printStackTrace();
}finally{
try   {
if(dis   !=null)   dis.close();
if(s   !=null)       s.close();
}   catch   (IOException   e)   {
e.printStackTrace();
}
          }
}
}
}





[解决办法]
这个好像是跟对象序列化有关,一般情况下不需要理会的
[解决办法]
我遇到,也是不予理会。

热点排行
Bad Request.