• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why Serialization?  RSS feed

 
sirisha makkapati
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • 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..
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • 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 ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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.
 
Md. Mohd
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
 
Adhir Gupte
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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.
 
Chris Ringer
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Guru dhaasan
Ranch Hand
Posts: 126
Java Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!