Go Premium for a chance to win a PS4. Enter to Win


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

Posted on 2004-10-28
Medium Priority
Last Modified: 2011-09-20
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.

Question by:bobwood2000
LVL 11

Expert Comment

ID: 12435089
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?
LVL 92

Expert Comment

ID: 12439772
serialVersionUID is not mandatory, but highly recomended.

Accepted Solution

grim_toaster earned 1000 total points
ID: 12444204
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".


Author Comment

ID: 12454716
Problem solved! Thank you.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

916 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