java – Client-server interaction through serialization


Hello everyone. I am setting up client-server communication via serialization.

I have a wrapper class in which I put the name of the class and the method that I need to call on the server. it is serialized before being sent to the server, and there, accordingly, it is deserialized.

The question is this:

Some methods on the server should return some objects to me. For example an object of the User class. The server contains, suppose, a jar file from which the server learns about such a class. How does the client know about this class?

After all, I understand that the wrong approach would be to duplicate two files with this class on both the client and the server?

Then, if this class changes on the server, will an error be generated during serialization / deserialization? Or not?


From experience I will say that you do not need to use serialization for this, because, as you guessed it yourself, you will have to duplicate fields and classes and even directories in the project. Better use JSON or xml . The first one converts java objects to javascript object, and the second one converts to xml and sends as a string. The easiest, most popular and convenient ways

Scroll to Top