J2ME in a Nutshell

Tis a rare thing, a technical Rant, for something that is such a popular topic, but what in the hell is wrong with J2ME? Java, version 2, Micro Edition, has become the little darling of the wireless industry. The press talks it up, middle managers are scrambling for news on it, and upper management has a hard on for it, yet it’s becoming the biggest pooch screw since Microsoft‘s Bob. Lets address them, one at a time shall we?

The press – simply put, the press is anti-Microsoft. It’s well known and documented. Right or wrong, whether I agree or not, it’s the truth. So every time someone else (Sun) comes out with something new (Java related) it gets propelled into the spot light and comes gospel. Truth is that most of Microsoft’s new technology (.NET) has been turned over to ISO committees for validation and verification to keep an open standard. Will it always stay that way? Who knows. What I do know is that Sun refused and continues to refuse to give control of Java to the same ISO boards. In their latest attack, Sun cries about Web Services… what’s the problem here? They’re glorified web servers spitting out XML. How is that “extending Microsoft’s monopoly to the Internet”? Here’s a suggestion for Sun: Come out with something better and people will switch to it! Naive? Hardly. I just don’t like whiners.

Upper management – I have no idea. In general, I can’t figure this group out. In some cases, they have business reasons for doing things and in others they are just another parrot repeating the press. What I have learned is that even if you have two degrees (bachelors and masters), a decade of experience, and countless certifications in the field, your opinions won’t count for dick when they’re compared to an executive’s buddy, spending a weekend on his boat, and talking about a cool new phone that is J2ME enabled and can make free calls to 1-900 numbers. Trust me. They wouldn’t know a J2ME complaint phone is if dropped in their pocket, but they do know they have to have it today. Why? Doesn’t matter – you aren’t upper management b/c you’re reading this, so you couldn’t figure it out either. What I do know, is that I told someone the other day that my car was J2ME compliant because it could carry a phone that ran with a J2ME virtual machine – it’s even J2EE compliant because you could put a Linux server in the trunk. Went over well, that.

Middle managers are the poor bastards that get told by upper management that they need to support new technologies with no budget and no resources, without any explanation, and have it done by 5:00 PM today, or else the world will end causing a decline in revenues. Enough said.

The problem is J2ME itself. J2ME is supposed to be this grand, compile once and run everywhere type thing. Sound familiar? It should. This is what Java was supposed to do to the PC, but the different iterations and ownership of Virtual Machines caused all sorts of incompatibilities. It simply doesn’t work. Oh, and how is it supposed to work? You compile your Java/J2ME code into P-code; a quasi-compiled state. This P-code goes to the Virtual Machine which then interprets it at runtime. It translates it on the fly. This is fine for a P4-class PC, but a little itty bitty phone with a 33MHz processor? Excuse the expression, but are you fuckin’ nuts??? This is why VB went from P-code in version 4 to compiled code in version 6. P-code is slow; it might be portable but it’s slow. So on to portability. There is a standard. It’s limited but it works: MIDP. The MIDP standard allows you to make MIDLets, which can run on any MIDP capable device. It includes a set of UI classes that are pretty good, an HTTP connection class, and some other neato keen stuff. However, when you give it to a KVM, the KVM will decide what to do with the UI requirements. I had an application that had it’s soft button assignments move, because the phone didn’t want them where the programmer suggested they go. This is P-code – that means the VM will have a say (if not the final say) in what actually happens. All of your code in J2ME is used as a suggestion to do certain things – there’s no guarantee that the VM will do so. Also, the same MIDLet will run on a Palm device, a RIM pager, and some other types of phones… the commonality? There isn’t one. Different size screens, color types and depths, and input methods are all standardized by the MIDP standard and you don’t have to worry about it. That’s good, but then you also can’t control it! One VM, when you pressed a phone keypad button, starts with a number instead of a letter while in an edit box – this is the only handheld device I’ve ever seen to do this… I can’t explain it, nor change it. My P-code is only a suggestion.

So what if you want more control? What if you want a custom interface with UI that makes use of all the device parameters and screen sizes/color? You have to go to a “native” J2ME SDK. You get to keep the MIDLet but now you need a third party SDK for extra and specific classes. You will also might need to work through your own socket communications, if you need any. Oh, and don’t count on using all of your UI controls that you get with the MIDP classes; the custom versions in the SDK might be subtly different for the different devices. Well, at least you have the SDK from the people’s device you’re targeting, right? Did you know, that for the US alone, there’s a special SDK for RIM pagers, Motorola phones, Sprint PCS phones, Nokia phones, and Nextel phones? No lie. I have see them with my own eyes. So what does this mean? That means you need a version of a Java Application that’s compiled specifically for each of these different SDK’s – maybe even for each of the different devices that these SDK’s support! It’s hard to say – I haven’t gone down this road yet.

The bottom line? If you think that J2ME is the Holy Grail, you’ve been snowed – you also probably believed (or still believe) that XML will save us from the hell of interoperable incompatibility and that if you dump an XML document on someone, then all the problems are over. (Actually, XML will be covered in another Rant, but I have to take that shot at people whenever I can.) Not only have ya been snowed, but you haven’t investigated your “cup of life”, there either. This is nothing new – the J2ME stuff has been swirling for a couple of years, so this is well known by many, although obviously not be enough.

If you’re going out into the J2ME world, go with a large sword cuz there be dragons out there.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.