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
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 ---
Code:
import com.sun.j3d.utils.geometry.ColorCube;
public class DoSerialize implements java.io.Serializable
{
public ColorCube cc;
}
And the errors are ----
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......
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
Re: Java 3d object serialization problem
Quote:
Originally Posted by
Norm
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?
Re: Java 3d object serialization problem
Quote:
Originally Posted by
mitra
By dafult ColorCube object of java 3d is already implemented serializable interface
By what dafult? Have you read the API?
db
Re: Java 3d object serialization problem
Quote:
Originally Posted by
DarrylBurke
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