I create my class in a client and use a server for communication between client and server, but I have a problem to convert this class. I send an object of my class from the client to the server, but the server notices this object is not from the same class.
My class implements Serializable and I use ObjectInputStream and ObjectOutputStream to send and receive this object.
How can I let the server know that this object is from the same class as in the client?
//Client site.
toServer = new ObjectOutputStream(myClient.getOutputStream());
fromServer = new ObjectInputStream(myClient.getInputStream());
toServer.writeObject(new MyClass("12345",12345));
//Server site.
fromClient = new ObjectInputStream(connectFromClient.getInputStream());
toClient = new ObjectOutputStream(connectFromClient.getOutputStream());
MyClass message = (MyClass) fromClient.readObject();
Create a third project, which has the classes used by both the client and the server and create a jar. Then add that jar to the classpath of the server and the client application.