The serialver is a tool that comes with JDK. It is used to get serialVersionUID numbers of one or more Java classes. Basically, a serializable class must declare a constant named serialVersionUID (either explicitly by the programmer or implicitly by the compiler) like this:

public class User implements Serializable {

	private static final long serialVersionUID = 1234L;
	
}
The serialVersionUID number is important when dealing with the serialization/de-serialization of objects of a class. The serialver command is helpful in case we want to know that number without having source code of the class. Its syntax is as simple as follows:

serialver [-classpath classpath] [-show] [classname...]
The -classpath option specifies where to look for the classes (in directories or jar files, separated by semicolon marks ;). The -show option displays a simple user interface that allows the user to enter a full class name and then press Enter key or click Show button to display the serialVersionUID number.

Now, let’s see some examples.

 

References:

 

Java Serialization Tutorials:

 

Other Java Tools Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.