Re: serialver?




CapCity wrote:
OK, experienced developer, but new to Java (and eclipse, which is another
hurdle until I get used to it).

I inherited a project that has several classes that implement Serializable
and have a serialVersionUID variable. I created a new class that is a clone
of several of these existing ones and want to generate a serialVersionUID
for it. Looking on-line, I found several descriptions for serialver. I've
had no luck with it. I keep getting "class xxx not found" messages.

The file is a few folders deep, say src/dir1/dir2/dir3/myclass. From what
folder do I execute serialver and what do I use as the class name? The
package it belongs to would be dir1.dir2.dir3

Found an eclipse plug-in, but says the feature is "not available here", or
something like that.

I think an issue may be that these are all in .java files and not .class
files. But all the ones with serialVersionUIDs are .java files.

Also, do I need to generate a new one everytime the class changes?

BTW, the person who originally developed this doesn't remember how they were
generated.

Thanks!

Perhaps there's a better way, but...

In Eclipse when I clone a class that implements Serializable, to get a
new serial version number I delete the line that declares the serial
version UID and then a little plus-sign or something appears (maybe I
have to save to get this) next to the class declaration line... I think
I double-click that or right click it (I don't pay too much attention)
and I get a list of things to do, one of which is to create a new
serial version number UID. Selecting it recreates the line with a new
number.

.



Relevant Pages

  • Re: serialVersionUID in Eclipse
    ... > Generierung dieser UID. ... wenn ich auch die entsprechende Compilereinstellung aktiviert ... > habe (WARNUNG oder FEHLER bei fehlender serialVersionUID). ... Die UID ist im Prinzip das gleiche wie ...
    (de.comp.lang.java)
  • Re: Serialization and Versioning of Classes
    ... > 1) Is the usage of hard coded serialVersionUID an official java feature ... You don't ensure compatibility to future versions by ... setting the UID now. ...
    (comp.lang.java.programmer)
  • Re: serialVersionUID in Eclipse
    ... >>>trotzdem automatisch eine serialVersionUID zu generieren? ... dass ich neben der reinen UID noch ein paar ... andere Sachen mache, damit Serialisierung und Deserialisierung ...
    (de.comp.lang.java)
  • Re: Problems retrieving object through rmi
    ... *slaps himself for not thinking of that!* ... But don't forget that you are now responsible for maintaining the UID. ... will be different) then you should update the serialVersionUID. ... University of Leicester, Leicester, LE1 7RH, UK ...
    (comp.lang.java.programmer)
  • Re: Question re serializable
    ... I've got dozens of messages of this kind and the classes that get the warning message extend a variety of different classes, including JFrame, JDialog, JApplet, but also classes that have nothing to do with GUIs, like some homegrown Exception classes. ... I'm particularly foggy on which value I'm supposed to use in the serialVersionUID constant if I choose to code one, ... The Bad Thing that may happen if you do supply one is that you really do change the serialised format, but not the UID. ...
    (comp.lang.java.programmer)