You can use Antenna (there is a plugin for Eclipse, and you can use it with the Ant build system), I use it in my projects as you described, and it works fine :)
EDIT: here is an example related to @ WhiteFang34 solution, which is the way:
In your main project:
//base class Base.java public abstract class Base { public static Base getInstance() { //#ifdef ANDROID return new AndroidBaseImpl(); //#elif J2ME return new J2MEBaseImpl(); //#endif } public abstract void doSomething(); } //Android specific implementation AndroidBaseImpl.java //#ifdef ANDROID public class AndroidBaseImpl extends Base { public void doSomething() { //Android code } } //#endif //J2ME specific implementation J2MEBaseImpl.java //#ifdef J2ME public class J2MEBaseImpl extends Base { public void doSomething() { // J2Me code } } //#endif
In your project that uses the main project:
public class App { public void something {
If you want to create for Android, you simply define the symbol of the ANDROID or J2ME preprocessor if you want to build for the J2ME platform ...
Anyway, I hope this helps :)
sinek source share