Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse : Cannot generate a serial version ID

Tags:

java

eclipse

I have an issue with Eclipse 3.6 (Helios) :

Anytime I want to generate a serial version ID (serialVersionUID) for a class that extends a serializable class, I get the following message :

The following error occured : Could not find class file. Make sure the file is compilable.

What am I doing wrong ?

Thank you.

like image 786
Tity Avatar asked Jul 15 '13 10:07

Tity


People also ask

How do I get a serial version ID?

File -> Settings -> Editor -> Inspections -> Java -> Serialization issues : Find serialization class without serialVersionUID and check it. Back to the editor, clicks on the class name, ALT + ENTER (Windows), it will prompts the Add serialVersionUID field option. A new serialVersionUID is auto-generated.

How do I generate serialVersionUID in eclipse?

For Eclipse IDE, move the mouse over the serialization class, or click on the serialization class and press CTRL + 1 .

What is meant by serialVersionUID in Java?

The SerialVersionUID must be declared as a private static final long variable in Java. This number is calculated by the compiler based on the state of the class and the class attributes. This is the number that will help the JVM to identify the state of an object when it reads the state of the object from a file.

What is a serialVersionUID?

SerialVersionUID is a unique identifier for each class, JVM uses it to compare the versions of the class ensuring that the same class was used during Serialization is loaded during Deserialization. Specifying one gives more control, though JVM does generate one if you don't specify.


1 Answers

In my case, I've solved this problem by the following way:

Right click the project, "Build Path" -> "Configure Build Path" -> "Source" tab, remove paths tagged "missing".

like image 87
Po Zhou Avatar answered Oct 25 '22 04:10

Po Zhou