6

Serializable classes are package dependent?

view full story
linux-howto

http://www.daniweb.com – So, a while ago I wrote a SerializableImage class in order to easily bundle several images together into a single file. The class worked fine, both serializing, file I/O and drawing. In another project I'm working on I successfully used a copy of this SerializableImage class, until recently. I had decided that I wanted my project in a "real" package, rather than the default_package (due to some jar-ing problems). Now, all of a sudden, my SerializableImage class starts generating ClassNotFound exceptions when I try to cast the objects from my image file to SerializableImage. Nothing in the class has changed except that I added package myPackage; to the header of my classes. Class structure and serialVersionUID are exactly the same. The class is found, since I'm able to instanciate SerializableImage objects. Does anyone know a way to get around this problem, or will I have to admit defeat, change serialVersionUID and re-generate all my image bundles again with the new class version? Thanks for your time! Emil Olofsson (General)