> I am part of a small J2ME projekt that has both a server side (J2EE)
> and a client side (J2ME, MIDP 1.0). Now I have found a small problem,
[quoted text clipped - 8 lines]
> *ONLY* difference is that one implements java.io.Serializable. Is there
> a better way? We would like to use a single class file for both sides.
The technique I've used is to use my own interface xyz.Serializable
instead of java.io.Serializable. The version of xyz.Serializable
compiled for J2SE/J2EE implements java.io.Serializable. The J2ME version
does not.
Alternatively you can use sed or something similar (there's a suitable
task in ANT) to remove the implements java.io.Serializable when
compiling for J2ME. Or equivalently, to add it when compiling for J2SE/J2EE.
> First I thought that we could simple create the package java.io on the
> J2ME side, with the interface Serializable. But what would happen if
> the application is run on a MIDP 2.0 phone, that already has the
> java.io.Serializable interface? It seems that it could cause some
> trouble...
If the phone already has java.io.Serializable, then it will just use its
own copy. However, if it doesn't have it, then it will probably complain
about loading classes into java.*.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
jimi_usenet@hotmail.com - 29 Mar 2006 20:50 GMT
> The technique I've used is to use my own interface xyz.Serializable
> instead of java.io.Serializable. The version of xyz.Serializable
> compiled for J2SE/J2EE implements java.io.Serializable. The J2ME version
> does not.
That worked like a charm. Thanks for the tip, Tom!
/Jimi