serialVersionUID in Netbeans

Most of the time, I use Netbeans when I have the choice. What I don't like about Eclipse and is getting me worried time to time is when the IDE freezes for a long time when you're not really doing anything.

Last week, I needed to build a simple Java project (Maven based build), about 50 000 lines of code(from sloccount). The project contains one core project and few sub projects. Eclipse took about 30 minutes to import the project and set up the classpath. That performance was achieved under a Quad Core, 2 GB of RAM, which is amazing. I had only Eclipse, Firefox and a terminal opened. I tried with both q4e and m2eclipse plugins, same results, I could hear my CPU making lots of noise. I had time to start cooking, boil water for coffee and do some other things, before the IDE was ready to use.

One of many missing features in Netbeans is the ability to generate the serial version ID for a serializable class. With Eclipse, you get the warning all the time, and you can choose between:

  • ignoring it
  • adding the annotation @SuppressWarning("serial")
  • generating the serial version id.

Available plugins for Netbeans
There are two plugins available for Netbeans, that I am aware of : UUIDGenerator and serialVersionUID generator. I only have success with UUIDGenerator (most of the time, I am running the latest development build under Linux and Windows and lately Mac OS Leopard).

Enabling Serialization warnings
Under Tools->Options->Editor->Hints->Standard Javac warnings, select Serialization. That way, you'll see a marker notifying you that you're missing the declaration of a serialVersionUID field.

Generate the serial version ID
You can generate the serialVersionUID using the shortcut Control-ALT-Z. You can copy the generated contents to the clipboard and paste it inside your class.

Bookmark the permalink. RSS feed for this post.

3 Responses to serialVersionUID in Netbeans

Michal Hlaváč said...

Hello, what kind of problem did you have with serialVersionUID generator plug-in? It works very well for me.

Yves Zoundi said...

Hello Michal,

My problem was with the early Netbeans 6.x builds development version. The plugin was simply not working.

I assume that you're using the latest version of the plugin which was updated in the meantime :-). The last updated date is Aug 08, 2009.

I don't think that the plugin would work if you use a previous early 6.x build with the initial version of the plugin.


ciju said...

Hi thanks for the post.helped me to learn and use serialVersionUID

Swedish Greys - a WordPress theme from Nordic Themepark. Converted by