Libaries and Interfaces

When porting a game from j2me to j2se I decided to abstract all the graphics/io calls and make a library with two implementations, one for j2me, one for PC.

Now the code in my games is the same but I need two projects in eclipse one linking the PC lib and the other the ME lib.

I have looked that libraires like Xalan uses interfaces for all its calls, and only at runtime the implementation is instantiated.

I want to abstract completely my implementation and use interfaces, but I don’t know how to instantiate my implementing clases; Do I need some kind of AbstractFactory?

Pretty much; you choose an appropriate factory at run time which implements a factory interface; and the concrete factory instantiates concrete implementations of your library interfaces.

Cas :slight_smile:

are you looking for http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Service%20Provider ?

And have different class-paths in your run configurations.