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

Posted on 2004-10-28
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 37

    Expert Comment

    LVL 11

    Expert Comment

    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

    serialVersionUID is not mandatory, but highly recomended.
    LVL 7

    Accepted Solution

    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

    Problem solved! Thank you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Title # Comments Views Activity
    bigDiff challenge 17 45
    tripleUp challenge 7 44
    post4 challenge 28 56
    NotAlone Challenge 20 56
    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

    875 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now