1. Using Eclipse IDE
2. Using IntelliJ IDEA
3. Using built-in JDK command
4. Using 1L
Read Also : What is serialVersionUID
1. Using Eclipse IDE
In Eclipse IDE, move the mouse over the class name implementing the Serializable interface, or click on the Serialization class and press CTRL + 1.2. Using IntelliJ IDEA
In IntelliJ Idea, we have to manually enable the auto-generate serialVersionUID option. You can find the detailed explanation here.3. Using built-in JDK command
JDK provides the built-in command to generate a serialVersionUID automatically. The command is serialVer.Syntax
serialVer className
In the below example we are generating the serialVersionUID of the HelloWorld class. Make sure the HelloWorld class is implementing the Serializable interface.
4. Using 1L
Last but not the least, you can use the serialVersionUID=1L. It will be enough for most of the cases.Syntax
private static final long serialVersionUID = 1L;
That's all for today, please mention in the comments in case you have any questions related to how to generate serialVersionUID in Java.