• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7952
  • Last Modified:

error: serializable class does not declare a static final serialVersionUID field of type

I download some open source software, and now I'm try to open it in Ecplise. However, I get the following type of error 92 times. The only thing that is different about these error messages is the name of the class they apply to:

typical error message:
The serializable class CrawlHost does not declare a static final serialVersionUID field of type long

corresponding line:
public class CrawlHost implements Serializable {

Is the need for declaring a field name serialVersionUID specific to my version (1.5) of Java? Or, please tell me what you think this error message might mean.

1 Solution
Sun releases a program "serialver" to generate code for inclusion, which you run on your class in question (with the class in the classpath).
AFAIK, serialVersionUID is not mandatory, and if not provided will be added by the compiler (but in a broken fashion, in that each compile can result in a different one, even if the code is 100% identical!) - Is this a compile error with Java 1.5, or a warning?
serialVersionUID is not mandatory, but highly recomended.
It's nothing to do with your JDK, it's a new compiler style check introduced in Eclipse 3.1.  If it really annoys you, you can  diable this check (which is Enabled by default) by going to:

Preferences (on the menu) --> Java (on the tree-chart) --> Compiler (under Java) --> Style (tab) and changing the"Serializable class without serialVersionUID" drop down to "Ignore" instead of "Warning".

bobwood2000Author Commented:
Problem solved! Thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now