java.lang.ClassNotFoundException: com.chat.common.User错误,求大神帮忙看看
public ChatServer()
{
try {
System.out.println("我是服务器在8888监听...");
ServerSocket ss=new ServerSocket(8888);
while(true)
{
Socket s=ss.accept();
//接受客户发来的信息
ObjectInputStream ois=new ObjectInputStream(s.getInputStream());
//User u=(User)ois.readObject();
Object o = ois.readObject();
System.out.println(o.getClass());
User u = (User) o;
System.out.println("服务器接收到的ID:"+u.getUserId()+" 密码:"+u.getPasswd());
Message m=new Message();
ObjectOutputStream oos=new ObjectOutputStream(s.getOutputStream());
if(u.getPasswd().equals("123456"))
{
m.setMesType("1");
oos.writeObject(m);
}else{
m.setMesType("2");
oos.writeObject(m);
//关闭连接
s.close();
}
}
public boolean sendLoginInfoToServer(Object o)
{
boolean b=false;
try {
System.out.println("正在连接...");
Socket s=new Socket("127.0.0.1",8888);
ObjectOutputStream oos=new ObjectOutputStream(s.getOutputStream());
User u = (User) o;
oos.writeObject(u);
ObjectInputStream ois=new ObjectInputStream(s.getInputStream());
Message ms=(Message)ois.readObject();
if(ms.getMesType().equals("1"))
{
b=true;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
}
return b;
}
public class User implements Serializable{
private static final long serialVersionUID = 511142319526449270L;
private String userId;
private String passwd;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String passwd) {
this.passwd = passwd;
}
public class Message implements java.io.Serializable{
private String mesType;
public String getMesType() {
return mesType;
}
public void setMesType(String mesType) {
this.mesType = mesType;
}
调用
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.out.println("OK");
// new ChatFriendList();
// this.dispose();
if(evt.getSource()==jButton2)
{
ChatClientUser chatClientUser=new ChatClientUser();
User u=new User();
u.setUserId(jTextField1.getText().trim());
u.setPasswd(new String(jPasswordField1.getPassword()));
//chatClientUser.checkUser(u);
if(chatClientUser.checkUser(u))
{
new ChatFriendList();
//关闭登陆界面
this.dispose();
}else{
JOptionPane.showMessageDialog(this,"用户名或密码错误!");
}
}
}
错误
java.lang.
ClassNotFoundException: com.chat.common.User
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)