Generating serialVersionUID in IntelliJ IDEA

24 Oct
2008

A good practice or even a must when creating a Serializable classes is to provide a stream unique indentifiers, commonly called as serial version UID. This unique private static long number can be created using the serialver command. But the question is, can we generate it directly from IDEA? Eclipse has this feature!

Actually the IntelliJ IDEA has the feature but it was turned off by default. Now, to make the feature available you need to enable it first, go to:

Settings -> Errors -> IDE Profiles -> Default -> Serialization Issues -> Serializable class without ’serialVersionUID’

After configuring it the IDEA code inspection will warn you everytime you create a Serializable class without a serialVersionUID. By pressing the Alt + Enter a unique number will be generated for you, so you don’t need to switch to the console anymore. Below is the example screen from the IDEA editor:

Serial Version UID

Comment Form

top