The docs for java.io.Serializable are probably about as good an explanation as you'll get:

The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. A serializable class can declare its own serialVersionUID explicitly by declaring a field named serialVersionUID that must be static, final, and of type long:

ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;

If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization. Therefore, to guarantee a consistent serialVersionUID value across different java compiler implementations, a serializable class must declare an explicit serialVersionUID value. It is also strongly advised that explicit serialVersionUID declarations use the private modifier where possible, since such declarations apply only to the immediately declaring class โ€” serialVersionUID fields are not useful as inherited members.

Answer from Jon Skeet on Stack Overflow
๐ŸŒ
HubSpot
product.hubspot.com โ€บ blog โ€บ java-11-dont-rely-on-generated-serialversionuid
Java 11 Upgrade Tip: Don't Rely on Generated serialVersionUID
In Java 11, however, JEP-181 landed. This JEP enhanced the class file format and JVM to directly support these inner class accesses, which eliminates the need to generate a synthetic constructor. And now we fully understand why our serialVersionUID changed when targeting Java 11.
๐ŸŒ
Reddit
reddit.com โ€บ r/java โ€บ java 11 upgrade tip: don't rely on generated serialversionuid
r/java on Reddit: Java 11 Upgrade Tip: Don't Rely on Generated serialVersionUID
June 24, 2020 - Java builtin serialization isn't exactly fast either. ... Apache wicket uses it. That said, I never had any issues with it. ... This is an excellent case and reminder to manually set serialVersionUID. In Scala use @SerialVersionUID.
Discussions

java - What is a serialVersionUID and why should I use it? - Stack Overflow
Eclipse issues warnings when a serialVersionUID is missing. The serializable class Foo does not declare a static final serialVersionUID field of type long What is serialVersionUID and why is it More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to manually generate a serialVersionUID with Eclipse?
Delete the private static final long serialVersionUID. It should give you a warning by the class name, and if you hover your mouse over it, it should give you the option to generate the ID. More on reddit.com
๐ŸŒ r/java
5
1
September 29, 2014
java - What means 1L serialVersionUID? When could I use this default value 1L? - Stack Overflow
There are 3 ways to define the serialVersionUID : 1. private static final long serialVersionUID = 1L; (Default) 2. private static final long serialVersionUID = -8940196742313994740L; (Generated) 3... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Java Externalizable serialVersionUID - Stack Overflow
If I implement Externalizable, will I need to specify serialVersionUID in that class for version compatibility? In other words, does Java check serialVersionUID while deserializing Externalizable More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Oracle
docs.oracle.com โ€บ en โ€บ java โ€บ javase โ€บ 11 โ€บ docs โ€บ api โ€บ java.base โ€บ java โ€บ io โ€บ Serializable.html
Serializable (Java SE 11 & JDK 11 )
January 20, 2026 - The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization.
Top answer
1 of 16
2616

The docs for java.io.Serializable are probably about as good an explanation as you'll get:

The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. A serializable class can declare its own serialVersionUID explicitly by declaring a field named serialVersionUID that must be static, final, and of type long:

ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;

If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization. Therefore, to guarantee a consistent serialVersionUID value across different java compiler implementations, a serializable class must declare an explicit serialVersionUID value. It is also strongly advised that explicit serialVersionUID declarations use the private modifier where possible, since such declarations apply only to the immediately declaring class โ€” serialVersionUID fields are not useful as inherited members.

2 of 16
526

If you're serializing just because you have to serialize for the implementation's sake (who cares if you serialize for an HTTPSession, for instance...if it's stored or not, you probably don't care about de-serializing a form object), then you can ignore this.

If you're actually using serialization, it only matters if you plan on storing and retrieving objects using serialization directly. The serialVersionUID represents your class version, and you should increment it if the current version of your class is not backwards compatible with its previous version.

Most of the time, you will probably not use serialization directly. If this is the case, generate a default SerialVersionUID by clicking the quick fix option and don't worry about it.

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ serialversionuid-in-java
SerialVersionUID in Java - GeeksforGeeks
August 11, 2021 - Java Collection ยท Last Updated ... which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization...
๐ŸŒ
Sulacosoft
sulacosoft.com โ€บ content โ€บ Java โ€บ SerialVersionUID โ€บ index.html
Java - Serial Version UID
For example, to find several versions of the same class (exception related to different serialVersionUID). Here we can use the command: // Replace 'YourExampleClass.class' with the class you want to inspect sudo find / -type f -name "*.jar" -exec sh -c 'unzip -l "{}" | grep "YourExampleClass.class" && echo "Found in: {}"' \; https://docs.oracle.com/javase/8/docs/platform/serialization/spec/class.html https://docs.oracle.com/en/java/javase/11/tools/serialver.html
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ serialversionuid-in-java
SerialVersionUID in Java - GeeksforGeeks
August 11, 2021 - We can configure our own SerialVersionUID for which we need 3 classes as follows: Random class which contains two variables which are going to Serialize, let it be 'Geeks' Class for sender side which is going to Serialize an object ยท Class for receiver side which is going to deserialize ... // Java program to illustrate Implementation of // User-defined SerialVersionUID // Main class // // Geeks which contains two variable which // are going to Serialize to // Illustrate Implementation of Serializable Interface class Geeks implements Serializable { // User-defined SerialVersionUID // Custom initialization private static final long SerialVersionUID = 10l; int i = 10; int j = 20; }
Find elsewhere
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ core java โ€บ what is the serialversionuid?
What Is the serialVersionUID? | Baeldung
January 8, 2024 - The serialVersionUID attribute is an identifier that is used to serialize/deserialize an object of a Serializable class.
๐ŸŒ
How to do in Java
howtodoinjava.com โ€บ home โ€บ serialization โ€บ guide to java serialversionuid
Guide to Java SerialVersionUID - HowToDoInJava
March 14, 2023 - Here the serialVersionUID represents the class version, and we should increment it if the current version of the class is modified such that it is no longer backward compatible with its previous version.
๐ŸŒ
Mkyong
mkyong.com โ€บ home โ€บ java โ€บ java โ€“ how to generate serialversionuid
Java - How to generate serialVersionUID - Mkyong.com
May 14, 2020 - Puts serialVersionUID=1L; It should be sufficient in most cases. ... Founder of Mkyong.com, passionate Java and open-source technologies.
๐ŸŒ
JetBrains
intellij-support.jetbrains.com โ€บ hc โ€บ en-us โ€บ community โ€บ posts โ€บ 4684018788626-How-to-generate-serialVersionUID-for-all-classes-in-a-project
How to generate serialVersionUID for all classes in a project โ€“ IDEs Support (IntelliJ Platform) | JetBrains
March 16, 2022 - When I say there is no quick fix, I mean there isn't a button on the inspection results for the JVM Language inspection that will correct all the issues like there was for the Java inspection. IDEA has the warning in each class and it can be selected to generate a serialVersionUID, but each class needs to be opened.
๐ŸŒ
Mkyong
mkyong.com โ€บ home โ€บ java best practices โ€บ java โ€“ what is serialversionuid
Java - What is serialVersionUID - Mkyong.com
May 14, 2020 - As we know that serializable is a marker interface it doesnโ€™t contain any method or variable ,when we are not define the serialVersionUID explicitly then JVM put a default one.my question is from where this static final variable comes from. ... The stream-unique identifier is a 64-bit hash of the class name, interface class names, methods, and fields. Also from Java docs โ€“ http://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification.
๐ŸŒ
Java2Blog
java2blog.com โ€บ home โ€บ core java โ€บ serialization โ€บ serialversionuid in java serialization
serialVersionUID in java Serialization - Java2Blog
January 12, 2021 - โ€œthe default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserializationโ€.
๐ŸŒ
w3tutorials
w3tutorials.net โ€บ blog โ€บ what-is-a-serialversionuid-and-why-should-i-use-it
What is serialVersionUID in Java? Why You Should Use It (Eclipse Warning + Problem Example) โ€” w3tutorials.net
The serialization runtime associates ... which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization...
๐ŸŒ
DZone
dzone.com โ€บ coding โ€บ languages โ€บ what is serialversionuid?
What Is serialVersionUID?
October 11, 2017 - It is used during deserialization to verify that the sender ( the person who serializes) and receiver ( the person who deserializes) of a serialized object have loaded classes for that object that are compatible with respect to serialization. In case a receiver has loaded a class for the object that has a different serialVersionUID than that used to serialize, then deserialization will end with InvalidClassException.
Top answer
1 of 8
20

What is the meaning? Is that useful?

Yes. The point of serialVersionUID is to give the programmer control over which versions of a class are considered incompatible in regard to serialization. As long as the serialVersionUID stays the same, the serialization mechanism will make a best effort to translate serialized instances, which may not be what you want. If you make a semantic change that renders older versions incompatible, you can change the serialVersionUID to make deserializing older instances fail.

If all classes have the same serialVersionUID 1L, is there no problem?

No - the serialVersionUID is per class.

2 of 8
8

This is explain here:

The serialVersionUID is a universal version identifier for a Serializable class. Deserialization uses this number to ensure that a loaded class corresponds exactly to a serialized object. If no match is found, then an InvalidClassException is thrown.


From the javadoc:

The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. A serializable class can declare its own serialVersionUID explicitly by declaring a field named "serialVersionUID" that must be static, final, and of type long:


Useful Links

  1. java.io.Serializable
  2. Why should I bother about serialVersionUID? (StackOverflow)
  3. serialVersionUID in Java Serialization
๐ŸŒ
Medium
medium.com โ€บ javarevisited โ€บ understanding-serialversionuid-in-java-07df4c57fc86
What is SerialVersionUID in Java? Understanding its Importance and Best Practices | Javarevisited
January 2, 2025 - Without an explicitly defined serialVersionUID, Java generates one based on the classโ€™s structure. Because the structure has changed, the serialVersionUID differs, making previously serialized objects incompatible with the new version.
๐ŸŒ
Temp Mail
tempmail.us.com โ€บ temp mail โ€บ blog โ€บ java โ€บ java's serialversionuid: an overview and its significance
Java's SerialVersionUID: An Overview and Its Significance
July 24, 2024 - The provided scripts highlight the significance of serialVersionUID in Java serialization. In the first example, the class Foo implements the Serializable interface with a serialVersionUID field. This feature is critical since it ensures that the class used during deserialization matches the version of the serialized object.