[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Java serialisation

Posted on 2005-04-07
8
Medium Priority
?
313 Views
Last Modified: 2010-03-31
Why would one want to put the following inside a class declaration

private static final long serialVersionID = 1L;

thanks in advance
0
Comment
Question by:inzaghi
  • 4
  • 3
8 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 1000 total points
ID: 13726784
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13726806
the Paragraph "SERIALIZATION AND CLASS VERSIONING"
0
 
LVL 3

Expert Comment

by:Mig-O
ID: 13726811
It doesn't really matters what you put there. But if theres a static value, you can add methods and the serializer would still read the same class in (even if it's not the same)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Expert Comment

by:Mig-O
ID: 13726820
You just have to make sure, it stays the same, as long, as the variables you are about to serialize remain the same.
0
 
LVL 3

Expert Comment

by:Mig-O
ID: 13726844
Oh, the more "complicated" values you find elsewhere are mostly the ones, the Serializer creates itself. Some IDE's like Eclipse support generating the serialID for you, beeing the same the Serializer in Java would create, when you don't give one expliicitly.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13726871
That's all nicely explained in the link I gave ;°)
0
 
LVL 19

Expert Comment

by:Jim Cakalic
ID: 13727010
Hi inzaghi,

It might also help you to look at the serialization spec and see how serialVersionUID is used and computed when you haven't specified a value explicitly (see particularly section 4.6). There's also a tool here to compute the serialVersionUID as the compiler would so you can seed the value with something sane. Later you can tell whether the class has changed by recomputing the UID value and comparing. BTW, it is 'serialVersionUID', not 'serialVersionID'.
http://java.sun.com/j2se/1.4.2/docs/guide/serialization/

Regards,
Jim Cakalic
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13727034
Thanks for accepting
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question