How to generate serialVersionUID for Serializable?

12,680

If you have a class which implements Serializable interface but doesn't specify a serialVersionUID, you'll get a warning. You can automatically ask Eclipse to fix that warning by clicking on the balloon which pops up on that line. Make sure you don't generate a random but a logical serialVersionUID i.e. 0 or 1 if this is the first draft of your serilizable class.

Share:
12,680

Related videos on Youtube

Adi Mor
Author by

Adi Mor

QA Group Leader

Updated on June 04, 2022

Comments

  • Adi Mor
    Adi Mor almost 2 years

    I have a class A that extends another class B that implements Serializable interface. I want to automatically generate the serialVersionUID for class A using the Eclipse.

    If class A was the class that implements Serializable Eclipse will have a error compilation. Please help me generate it automatically.

    class A

    public class QueryOptionModel extends BaseModelData {
    
    
    
    }
    

    class b - gxt api

    public class BaseModelData implements ModelData, Serializable
    
    • home
      home about 12 years
      Please provide some further details - which error do you receive?
    • Adi Mor
      Adi Mor about 12 years
      i don't receive that's the prob
    • tartak
      tartak about 12 years
      When your class's parent class extends a serializable class, |Eclipse asks you (warning) to provide a serialVersionUID. I don't get your problem
    • Adi Mor
      Adi Mor about 12 years
      the problem is that eclipse didn't ask me to provide a serialVersionUID
  • Adi Mor
    Adi Mor about 12 years
    but my class extent a class that implement a the Serializable, and don't show the warning
  • Sanjay T. Sharma
    Sanjay T. Sharma about 12 years
    I think you should post the code you are using. I do get a warning on my stock Eclipse installation.
  • Uli
    Uli about 8 years
    Probably your compiler settings ignore this. You can change this in Eclipse: Open the properties of your project, select Java Compiler => Errors/Warnings and set the item Serializable class without serialVersionUID to Warning or Error.