Friday, 22 April 2016

How to generate serialVersionUID ?


Using eclipse IDE
Put the mouse over the class name or select class name and press Ctrl+1
Choose option "Add generated serial version ID"


Using Java code
ObjectStreamClass osc = ObjectStreamClass.lookup(MySerializableCls.class);
long serialVerID = osc.getSerialVersionUID();
System.out.println(serialVerID);


Using JDK command : serialver
> serialver <className>

> javac MySerializableCls.java
> serialver MySerializableCls


Using JDK tool : serialver
> serialver -show

Provide full class name and click "Show"

No comments:

Post a Comment

Note: only a member of this blog may post a comment.