October 18, 2005 - It's all about the J2ME
Since J2ME is the future and all, or at least they've told us it is at JavaOne for the past three years, I started messing about with it to get a grip on what it is and what it can do.
If you have a good grounding with J2SE and Swing, it's not that hard to get into. *Most* of the stuff you're used to is there, sort of. The String class is thankfully mostly intact. The math libraries have taken a major hit, and the I/O packages are... strange.
Actual GUI work is different, and this is mostly good. Mobile devices don't really have the screen real estate to display dialog boxes and multiple windows, so you can only have one form displayed and active at a time. Makes sense.
So far, we're good.
Where things start to fall apart is actually running your program. For shits and giggles, I wrote an aim client and an implementation of the TOC (TOC2 to be exact) protocol. Displays the buddy list, lets you open/conduct multiple conversations, etc.
Problem is, there's a problem. What the problem is, couldn't tell you. The program works fine on the emulator. It works fine on the Nokia Series 60 emulator. It doesn't work so fine on the actual Nokia 6620. It works fine on some phones, and not others.
Turns out it's the 'Monty' Java VM that Nokia uses on their phones. The MFing Monty VM has issues reading (or finding out) if a inputstream on a socket has data available when it doesn't. You kinda just have to read and take your chances. Or, alternately, Monty VM doesn't really implement sockets correctly. I've seen both explanations listed, and the sad part is, if the first is correct, then the second must be as well.
In the J2SE world, this shit would not fly. Sun is pretty protective of what gets to call itself 'Java' and what doesn't. I have no idea why they aren't making a stronger push in this direction with J2ME, but I hope to hell they do soon.
Second, even with MIDP 2.0, the tookit is fairly spartan. Why is there no setBackground() on a form? Or on form items? What would this cost to implement? Whatever it cost, the benefits of having a decent looking application would more than outweigh it. Why must I extend Canvas and jump thru hoops just to make a form with a blue background?
And yes, I know about J2ME Polish. I've played around with it, and while it's nice and the screenshots look great, I don't want any strange ant routines changing my code to build a GUI, thanks. If I can't implement it by hand, on my own, I don't want to do it. And so far, I can't find any way to implement a polish style by hand, and that seems to be required for every component. (Altho, to be fair, I only spent an hour or so trying and I was pissed off about the networking issue).
So far, J2ME has lots of potential but isn't delivering. MIDP 2.1 maybe?