How to send object to server in java
<p>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. </p>

<p>My class implements Serializable and I use ObjectInputStream and ObjectOutputStream to send and receive this object.</p>

<p>How can I let the server know that this object is from the same class as in the client?</p>

<pre><code>//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();
</code></pre>
