Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Java in General and the fly likes Serialization in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Serialization in java" Watch "Serialization in java" New topic

Serialization in java

Bandita Patel

Joined: Mar 23, 2010
Posts: 25
When should we go for Serialization in a Java project? please give some example.Is it possible to serialize static variables? if yes then how & if no then why? please explain it...
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
Serialization should be used with caution. If your class changes frequently, you will get into serious trouble reading old serialized files. So, in general an xml format or a database is the better choice.

as for the static classes -->

JDBCSupport - An easy to use, light-weight JDBC framework -
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Note that "serialization" is a process, and it can be implemented in different ways. Out of the box, Java offers binary serialization (via the Object[In|Out]putStream classes) and XML serialization for JavaBean objects (via the XML[De|En]coder classes). As Sebastian mentioned, the binary format is brittle in the face of class changes, and may break when used between different JVM versions; so the XML format is a better choice these days (and is amenable to changes by non-JVM processes, which may or may not be useful in your circumstances).
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
a bandita wrote:When should we go for Serialization in a Java project? ...

What do you mean by "go for", what kind of objects do you want to
serialize and for what purpose?

Jim ... ...

I agree. Here's the link:
subject: Serialization in java
jQuery in Action, 3rd edition