Results 1 to 5 of 5
  1. #1
    mitra is offline Member
    Join Date
    Jun 2011
    Posts
    59
    Rep Power
    0

    Default Java 3d object serialization problem

    Hi friends....

    Try to writing a program which create binary file of java 3d objects(such as sphere, colorcube...) for later use. But before doing this I have to serialize the objects, but I can't do it, error occurred.

    lets see the program ----

    The following class is the main class which create a ColorCube object and write to binary file

    Java Code:
    import com.sun.j3d.utils.geometry.ColorCube;
    import java.io.*;
    
    public class SerializeDemo 
    {
       public static void main(String [] args)
       {
          DoSerialize e = new DoSerialize();
          e.cc = new ColorCube(1.4);
          try
          {
             FileOutputStream fileOut = new FileOutputStream("e://employee.txt");
             ObjectOutputStream out = new ObjectOutputStream(fileOut);
             try
             {
             out.writeObject(e);
             }catch(NotSerializableException i){i.printStackTrace();}
             out.close();
              fileOut.close();
          }catch(IOException i)
          {
              i.printStackTrace();
          }
       }
    }

    This is the serializable class ---

    Java Code:
    import com.sun.j3d.utils.geometry.ColorCube;
    
    
    public class DoSerialize implements java.io.Serializable
    {
       public ColorCube cc;
    }

    And the errors are ----
    Java Code:
    java.io.NotSerializableException: com.sun.j3d.utils.geometry.ColorCube
    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
    	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
    	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
    	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
    	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
    	at SerializeDemo.main(SerializeDemo.java:25)
    BUILD SUCCESSFUL (total time: 2 seconds)

    So how to overcome this problem?
    Please help.
    Thanks......

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,586
    Rep Power
    23

    Default Re: Java 3d object serialization problem

    Did you read the API doc for the error? The exception is a class that is defined in the API doc:
    Java Platform SE 7
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    mitra is offline Member
    Join Date
    Jun 2011
    Posts
    59
    Rep Power
    0

    Default Re: Java 3d object serialization problem

    Quote Originally Posted by Norm View Post
    Did you read the API doc for the error? The exception is a class that is defined in the API doc:
    Java Platform SE 7
    Thanks for your reply.
    Yes I read the API doc, but can't understand exactly what to do? By dafult ColorCube object of java 3d is already implemented serializable interface, so do I need to serialize it again?

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Java 3d object serialization problem

    Quote Originally Posted by mitra View Post
    By dafult ColorCube object of java 3d is already implemented serializable interface
    By what dafult? Have you read the API?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    mitra is offline Member
    Join Date
    Jun 2011
    Posts
    59
    Rep Power
    0

    Default Re: Java 3d object serialization problem

    Quote Originally Posted by DarrylBurke View Post
    By what dafult? Have you read the API?

    db
    Yes, I did and I was wrong. So I need to implement serializable interface to the ColorCube class
    Last edited by mitra; 01-17-2013 at 06:45 AM.

Similar Threads

  1. Replies: 4
    Last Post: 03-22-2012, 04:26 PM
  2. Object Serialization
    By rdjava in forum Advanced Java
    Replies: 1
    Last Post: 06-12-2011, 09:54 AM
  3. Replies: 3
    Last Post: 11-17-2010, 05:47 PM
  4. Prevent default write object serialization
    By nwboy74 in forum Advanced Java
    Replies: 5
    Last Post: 06-10-2010, 10:30 PM
  5. Object serialization
    By sky in forum New To Java
    Replies: 15
    Last Post: 11-23-2009, 01:10 PM

Tags for this Thread

Posting Permissions

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