aspose file tools
The moose likes Java in General and the fly likes  serialize an object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark " serialize an object" Watch " serialize an object" New topic
Author

serialize an object

Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

try to serialize an object of a class which implements Serializable, but the object includes a reference to an non- Serializable class then a ‘NotSerializableException’ will be thrown at runtime..how can we avoid this through prefixing transient ..!!

Mohamed Sanaulla
Bartender

Joined: Sep 08, 2007
Posts: 2925
    
  15

Saral Saxena wrote:try to serialize an object of a class which implements Serializable, but the object includes a reference to an non- Serializable class then a ‘NotSerializableException’ will be thrown at runtime..how can we avoid this through prefixing transient ..!!



Just look for how to use Transient key word.

Or the classes of those objects should also implement Serializable.

I would suggest you to start with a tutorial on Serialisation, it will help you a lot in clearing all these queries.


Mohamed Sanaulla | My Blog
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 5811
    
    5

Saral Saxena wrote:try to serialize an object of a class which implements Serializable, but the object includes a reference to an non- Serializable class then a ‘NotSerializableException’ will be thrown at runtime..how can we avoid this through prefixing transient ..!!



Please stop posting questions without doing any research first.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: serialize an object
 
Similar Threads
Serializable
Serialization Code
How to clone a object containing collection?
what is the output
java.io.NotSerializableException: