This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes The serializable class does not declare a static final serialVersionUID field  Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "The serializable class does not declare a static final serialVersionUID field  " Watch "The serializable class does not declare a static final serialVersionUID field  " New topic
Author

The serializable class does not declare a static final serialVersionUID field

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 359
What the heck is eclipse 3.2 talking about when it gives me the following warning:

"The serializable class XYZ does not declare a static final serialVersionUID field of type long"

Eclipse will generate such a field for me. I'm just creating a descendant of class Applet.

thanks,
siegfried
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24081
    
  15

If you explicitly put such a field into a serializable class, then you can use it to provide versioning for serialized data files containing this class. Class versions with the same SerialVersionUID have compatible serialized data, by definition, even if the class changes.

But if this doesn't matter to you, then just ignore the warning.


[Jess in Action][AskingGoodQuestions]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
For your information: in Eclipse you can change the importance of compile errors/warnings to your taste by Window - Preferences - Java - Compiler - Errors/Warnings. Specific this one can be found in the group called "Potential programming problems".


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
Robert Hill
Ranch Hand

Joined: Feb 24, 2006
Posts: 94
Disabling it might cause trouble down the road. If you mean to serialize an object the warnings will help you remember.

You can keep the warning turned on and either ignore it or get it out of sight by placing this line above public class ... : @SuppressWarnings("serial")
Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 359
Does someone have a favorite URL/tutorial that describes how one uses this unique value for versioning with serialization?

Thanks,
Siegfried
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: The serializable class does not declare a static final serialVersionUID field
 
Similar Threads
Compiler Warning when you implement Serializable interface
Eclipse Servlet Warning
serializable
eclipse error
Almost ready to hand up: Just cleaning up and have a few questions