M
M
Masteron2016-01-29 20:00:52
Java
Masteron, 2016-01-29 20:00:52

Server and client?

public class Message implements Serializable {
    private  String sight;
    private  String login;
    private  String password;
    private String message;
    // клиент
    public Message(String login, String password,String sight){
        this.login = login;
        this.password = password;
        this.sight = sight;
    }
    // сервер
    public Message(String message){
        this.message = message;
    }
    public String getSight(){
        return sight;
    }
    public String getLogin(){
        return  login;
    }
    public String getMessage(){
        return message;
    }
    public  String getPassword(){
        return  password;
    }
}

This class is equally implemented on both the server and the client, I use it to transmit data (well, not the point) and that's when I send this object on the client:
out.writeObject(client);
and the server receives it:
clientSend = (Message) in.readObject();
And as soon as the server receives this object immediately throws exceptions:
ava.lang.ClassNotFoundException: com.example.finalproject.Other.Message
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun .misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName (Class.java:348)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:626)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
at java.io. ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
at ClientThread.run(ClientThread.java:39 )
java.lang.ClassNotFoundException: com.example.finalproject.Other.Message
What is the problem and how can I fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FoxInSox, 2016-01-29
@FoxInSox

It is written in black and white:
The server must have the same classes as the client.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question