I\'m writing a program to send an object from one class to another class. Here is a short sample example of my program to represent the problem. As you can
You cannot ever deserialize a stream representing an instance of class X into an instance of class Y.
To solve your problem, you need to move the code for the Student
class to another file, say Student.java, and use that single class on your client code and on your server code.
Note that if you modify your class, in most cases you will need to redeploy the server (otherwise the client would send the server an stream representing an instance of class that is known only to the client).
Having two classes with the same name is not enough. The two classes need to have
I suggest you have a single, stand alone class which is common for both the client and the server. In a more complex project you might consider building these common components in a module which both the client and server modules depend on.
You are referencing two different classes. Student
which is an inner of ClientSide
and Student
which is an inner class of ServerSide
. You should move the Student
class to a different file.