J2ME vs J2SE

Hi there,

I was wondering what difference there is in writing for J2ME compared to J2SE?
I understand that there is quite a lot to fiddle with to make a game work on the different phones and such. But would it be possible to write a gameEngineCore kind och mechanism (2d) and develop for that playform, running on a J2SE in JPanel/JFrame/JAplet and then just (more or less) switch to J2ME? ???

If you hapen to have some references to some documents that perhaps cover this issue please post it.

  1. the gui is totally differently structured in J2ME then in J2SE
  2. in J2SE there are loads of other packages and classes that don’t exist in J2ME.

If you would develop a Game for J2SE you might use AWT or Swing, but when you try to port it - uups all those classes don’t exist there, you even have to cope with a totally different structure (because displays on mobile phones are so small)

Beside that, you cannot use floats or doubles on midlets :frowning:

So lets say I use Graphics2D or similar to blit and stay away from floats and doubles. have no GUI like swing or awt… It would be more or less an easy port?

  • you don’t have all the util stuff

java.awt.Graphics2D contains alot more functionality than javax.microedition.lcdui.Graphics.
Hell, java.awt.Graphics contains alot more functionality than javax.microedition.lcdui.Graphics !!

The most significant difference between development in J2SE and J2ME is program structure.
If you want an efficient program (in terms of both speed, memory usage and jar size) you need to throw away all the niceties of OO design.

Once compiled, obfuscated and optimised an optimal J2ME app. will have just 2 classes - one extending MIDlet, the other extending Canvas.
(Obviously the source-code itself will be far more structured, using Heirarchy transformation and other ‘magic’ to merge classes)

Everything else can be accomplished with arrays of primitives and Objects.

Its an art form to write optimal code while still maintaining readability.

I would say porting a J2SE game as a complete entity is impractical, perhaps even impossible.
but having a J2SE version is an excellent way of keeping your J2ME work focussed,
and so long as you have kept your code modular, there will be many parts you can reuse.