Results 1 to 6 of 6
  1. #1
    sunithamm is offline Member
    Join Date
    Dec 2009
    Posts
    19
    Rep Power
    0

    Exclamation serialization in java

    hi
    i have got the following exception while trying to serialize an object..

    java.io.NotSerializableException: sun.java2d.SunGraphics2D

    I was trying to serialize an object which uses swing components also...

    Can anybody help?

    Thanks in advance.

    Regards,
    Sunitha.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    843
    Rep Power
    6

    Default

    implement the Serializable interface.
    Ramya:cool:

  3. #3
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by RamyaSivakanth View Post
    implement the Serializable interface.
    That is not going to help since those classes are not theirs.

    Better read
    Discover the secrets of the Java Serialization API

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    843
    Rep Power
    6

    Default

    Implementing Serializable is the first criteria for Serialization.That is what I told......
    Ramya:cool:

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,769
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by RamyaSivakanth View Post
    Implementing Serializable is the first criteria for Serialization.That is what I told......
    He probably did but the error message was:

    Java Code:
    java.io.NotSerializableException: sun.java2d.SunGraphics2D
    That sun.java3d.... class definitely isn't his class so he probably doesn't have the source so he can't implement the Serializable interface on that class. There is an error somewhere else. That's what r035198x was trying to say.

    kind regards,

    Jos

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by RamyaSivakanth View Post
    Implementing Serializable is the first criteria for Serialization.That is what I told......
    I may be speaking out of hand, but on looking at his error:
    java.io.NotSerializableException: sun.java2d.SunGraphics2D

    it's with (as r-etc states) a class that we have no access to, the SunGraphics2D class, so simply implementing Serializable won't fix the OP's problem. Perhaps instead he will want to serialize data used by Swing models and then use it to reproduce the GUI,.... but I'm out of my league on this one.

    edit: I'm a bit slow on this response -- beaten by jos.

Similar Threads

  1. Java Serialization
    By Cbani in forum New To Java
    Replies: 18
    Last Post: 01-20-2010, 01:31 PM
  2. Serialization
    By thayalan in forum Advanced Java
    Replies: 4
    Last Post: 08-03-2009, 11:22 PM
  3. Java serialization
    By paul in forum Advanced Java
    Replies: 3
    Last Post: 04-10-2009, 09:58 PM
  4. about serialization
    By bishnu in forum New To Java
    Replies: 0
    Last Post: 12-19-2008, 10:13 AM
  5. Replies: 0
    Last Post: 04-04-2008, 03:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •