Added the serialization methods for Java.
Java serialization.