• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Why Serialization?

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Serialization means Writing State of an Object in to Byte Stream.In Which situation we have to write an object in to byte stream
Any one can tell me exact answer.
Thanks..
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see:
Carefully Choose One Forum/

This forum is reserved for servlet questions.

Again, welcome to JavaRanch and good luck with your question.
-Ben
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, there could be several reasons.

One reason very well known is RMI (Remote Method Invocation). With this technology it is possible that two separate JVM (Java Virtual Machine) transfer objects between each other.

In order to achieve this, many objects are serialized and transfered through the wire back and forth between the the two JVMs.

You could use serialization also to save the state of an application, so that when the application restarts you can recover to the particular moment when the application was closed.

And I am pretty sure many other could suggest dozens of other uses for serialization.
[ December 21, 2006: Message edited by: Edwin Dalorzo ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think of serialization any time you want to send an object over some path that isn't a real method call. As mentioned before you can send that byte stream to another computer over the network whether RMI, raw sockets or JMS, write it to a file or a database, or whatever you need.

Java's "serialize" operation generates a special Java format, but we use the word "serialize" to talk about converting your object to and from XML or CSV or delimited strings or any other format.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The real use of serialization is whenver you are transfering some data on the n/w. Lets say that there is an application that works with Mobile and server . The mobile phone acts as the client for such application. Now in this case if the mobile/user request some data from the server on the device , then the data that is sent from the server must be in the exact order as it was on the server . Thus to achieve this goal serialization is required.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"HereToLearn",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sending an ojbect across a network connection is one. This is used often in application server clustering.

Of course, writing to the file system is the most obvious. This can also be helpful when testing JSP pages with complex navigational structures.

-Cameron McKenzie
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Serialization is a very important concept. This proves a bliss in java when we are transferring data over network. Object serialization helps us when we need to transfer a file to a remote location. A serialize object is converted to a Byte Stream say a ByteArray[] then the recieving end converts the byte array to an object by deserializing the same.

adhir.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, just curious, what happens if an object (MyNeatClass version 1.0) is serialized and then before deserialized, someone installs a newer version of the class (MyNeatClass version 1.1) on the system? How does deserialization handle that? Thanks.

Chris
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, Chris, what happens may depend on several things.

You should read the Object Serialization Specification to understand better how the process works.

Look into the use of SerialVersionUID and specially pay attention to the Versioning of Serializable Objects chapter.
 
Ranch Hand
Posts: 126
VI Editor Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
think of this. you wrote a simple gaming program and when the user tries to close it, the user wants to start next time where he left off. These kind of things you can achieve using serialization
 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic