what is the library should I use ? what are the functions that help me?
It Depends:
If the other endpoint is in Java then Java serialization might be the fastest way to implement. But note supporting Java Serialization is not a trivial task and can be a chore to maintain over time. Just google "Java serialization gotchas" for some examples.
If the other endpoint is not in Java or future maintainability and compatibility is a goal, then I would recommend a more general reusable encoding. For this I would look into Google Protocol Buffers or Apache Thrift (I can post only 1 hyperlink).
Of course, there is always the option of using XML to encode your objects. :)
Personally, in our projects we have been using Google Protocol Buffers and in my opinion can't be beat for ease of use, maintainability, and most important in our case, compatibility between Protocol Buffer versions.