• 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

Serialization question I haven't seen in this forum

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand the concept of serialization and that it is used to transfer files over a network, but I'm a little confused about how often it is used. Aren't all or most java files transferred over a network? I mean if you are accessing a java program while surfing the internet or while playing an online game, aren't those files being transferred over a network? What other ways is a java program accessed if not over a network? I know that there are some applications that run on one's computer but I thought java was mainly an internet language.


 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vonique Leary wrote:I understand the concept of serialization and that it is used to transfer files over a network, but I'm a little confused about how often it is used. Aren't all or most java files transferred over a network?


Actually, in that context it's for transferring objects over a network; nothing to do with files.

All serialization is is a way of converting a Java object to a form that can be reconstituted at a later date, or on a different machine (with several caveats). This is called 'persistence', and it says nothing about whether it's stored in a file, a stream, or simply in a database.

I mean if you are accessing a java program while surfing the internet or while playing an online game, aren't those files being transferred over a network? What other ways is a java program accessed if not over a network?


Any way you can access any other program. But just for one: as a local program that runs on your desktop.

I know that there are some applications that run on one's computer but I thought java was mainly an internet language.


Then I suspect you've been blinded by the hype. What Java does have is several features that make it very useful for Web-based applications - not least, a very mature set of libraries and 3rd party products for doing just that - but otherwise, it's no different from any other language.

Winston
 
Vonique Leary
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, do most java programs that are accessed over a network use serialization or are there other ways to persist objects?

Thanks,
Vonique
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most network-aware programs probably use sockets directly. Java object serialization is tricky - it only works if you have a JVM on both sides of the connection, and you generally also need those two JVMs to be of the same version, otherwise serialization does not work. (At least the binary serialization used by Object[In|Out]putStream. The XML serialization of Javabeans offered by the java.beans.XML[En|De]coder classes is more resilient.)
 
Marshal
Posts: 79701
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice to see you again, Vonique.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vonique Leary wrote:or are there other ways to persist objects?


Well, it really depends on what you mean by 'persist objects'.

Databases have been persisting data in structured form for decades; and there are excellent tools like Hibernate around, that allow you to create Java objects from table data without a lot of the usual translation code. There are even "object" databases around, but I'm not up on the latest. Last I heard they were still pretty slow compared to regular RDBMS's, and development seemed to be a bit sporadic; but I could be completely out-of-date now.

And even an RDBMS can store a Blob, which is really all a serialized object is; the question comes more in how you key it.

And then there are all sorts of XML-based formats like Ulf said. I don't know if SOAP is still used much these days, but it was one of the first of those types of protocol.

Winston
 
Vonique Leary
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone, for your replies. It's a lot clearer now but it makes me realize just how much I don't know about networking, etc. Well, from what I have read on this forum, serialization is not on the test, so I am going to limit my knowledge about it to what I have already learned.

Nice to see you too, Campbell!

Von
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most Java programs that "run" over the internet are usually servlets that convert the output to HTML/Javascript and send it back to a web browser. The web browser renders the HTML/javascript on the user's sccreen. One way of looking at this is that the servlet is converting the result into user-friendly HTML, and HTML is the protocol used to "serialize" the result object. This is not really what Java considers as serialization

Some Java programs run as Java applets inside the client's browser. In this case, the server sends the Java class to the browser, and the browser executes the Java class in an embedded JVM. No objects are being serialized here

In some rare cases, Java applications/applets that are running on the client make a socket connection back to the server and communicate to the server using serialized objects. I don't think any serious application does this anymore.

 
Vonique Leary
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for that explanation Jayesh. That really helps to clear up why the only place I've ever seen serialization examples is in the prep book for the test. Things make so much more sense to me now!

Vonique
 
Sometimes you feel like a nut. Sometimes you feel like 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