Now I have been programming for some time and I just made a discovery today. I am writing an RMI application and I asked one of my methods to return an Enumeration. I keep getting errors(bcos I catch all errors and print my own error message). After some time I did printStackTrace() and the error was interesting. I am so sorry I couldn’t paste the stack trace, but it said something about serialising(Unsearalizable Error) so I checked the javadoc, and read the FAQ in the collections framework, what I discovered? The Java Collection Framework can not be Serialized.

This is a big discovery for me and It makes my work even more interesting because right now I am serializing a whole lot of Java Data Structures(dont ask me how, you will know later 🙂 ) major of them is the Hashtable.

You want to know what I am working on? Yes its a DHT you can find the project source at

Thats all for now folks




  1. swagata mallik said

    hi i am java learner

  2. Damjan said

    You’re wrong, java.util.Hashtable is serializable, probably the entries in it are not:

    import java.util.*;

    public class X
    public static void main(String args[]) throws Exception
    Hashtable hashtable = new Hashtable();
    hashtable.put(“Hello”, “world”);
    hashtable.put(“abc”, “123”);

    ByteArrayOutputStream store = new ByteArrayOutputStream();
    ObjectOutputStream stream = new ObjectOutputStream(store);

    ObjectInputStream inStream = new ObjectInputStream(new ByteArrayInputStream(store.toByteArray()));
    Object object = inStream.readObject();
    hashtable = (Hashtable) object;

  3. None said

    Collections can be serialized as long as the underlying objects in the collection are also serializable. Just make sure whatever is in the collection implements Serializable.

  4. i guess that’s the case, but I read clearly in the FAQ that collections can’t be serialised. Anyway tx for the contributions. I will dig further

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: