Skip to main content

MIDP 2.0 is just too much fun.

Posted by kathysierra on January 14, 2004 at 8:52 PM PST

I've spent the last few weeks playing with the Wireless Toolkit and MIDP 2.0. I've been in EJB-land for the last several years, so it's quite a shock going from big ol' gravel-hauling apps where it takes about a dozen objects to do Hello Bean, to these tiny little things where each object is precious.

But man oh man is it ever fun! The MIDP 2.0 Game API is so easy to use. In about 15 minutes after flipping through the API and the MIDP spec, I built a multi-frame animation, fully user-controllable, with automatic double-buffering, in about a dozen lines. And that 15 minutes includes creating the graphics! Until I started playing with it, I really had no idea how simple and clean it is to use GameCanvas and Sprite.

Of course, developing and deploying games for *real* devices is a *lot* more involved--I'm just using the emulators that come with the Wireless Toolkit. But I'm paying attention to the JTWI spec and trying to work within the constraints recommended for portability. And there's that little issue of, well, virtually no devices in the US that currently support MIDP 2.0. Still, I haven't done something so quickly and simply since the old Applet days. Except that was Java 1.02, when I had to walk uphill in the snow both ways to do my own double-buffering and, oh yeah, roll my own scrolling text area because the original one in AWT didn't exactly *work*.)

And it's a walk down memory lane, too. I'm looking at the new MIDP 2.0 Style Guide, and I could swear I'm reading word for word some of the things we used to all do and say about writing games 10 years ago--reduced indexed color palettes, extreme caution with object creation, putting up a splash screen while you wait for your first offscreen buffer to be displayed... but it's great fun and so satisfying to use the Wireless Toolkit--you get instant gratifcation. So different from writing enterprise beans or even servlets/JSP. You sit down at your editor, and a few minutes later you have this cool thing running in your choice of faux phones. (Although I have NO idea what's up with that scary-looking thing in the toolkit they call the "querty device". Yikes.)

So here's the part that sucks--NO SUPPORT FOR MAC OSX! Yes, you can do MIDP development on the Mac, with a little effort and configuration, but you cannot run the Wireless Toolkit. And apparently the Borland tool is no longer supported on the Mac either. In fact, there are apparently NO useful J2ME development environments for OSX. That just sucks. I *did* manage to get the Wireless Toolkit to run under Virtual PC on my Mac (thanks to Michael Yuan for letting me know that he got it running, or I wouldn't have tried). It's painfully slow, of course, but no slower than my ancient PC. And all because of one small piece of the toolkit that's apparently native? I've talked to Ariel, the lead developer of the WTK, I think, and he was happy to hear I had it running under Virtual PC, but did not know of--or have plans for--a Mac version. (He's still my hero for making the toolkit, though). I talked to the "Java guy" at Apple (Dan Steinberg introduced me to him at MacWorld, but I forgot his name) and Dan and I both made our points about wanting J2ME developer support on the Mac. I'm sure tons of other people have complained about this... I know there have been other blogs here and on O'Reilly about it. But I just thought I might as well add my own special way of complaining. : )

It's so easy to get started playing around with MIDP 2.0, that I don't know why more folks aren't trying it out. It takes, like, five minutes to install the toolkit (45 minutes if you have to first install Virtual PC on the Mac!), and you're good to go (all you need to do is tell it where your JDK lives). After that, it's so simple to write, build, and run (in emulation) your first little app:

1) Launch the KToolbar part of the toolkit. It comes up immediately with a little window and waits for you to Create or Open a project.

2) Create a new project just by giving it a name for your project and a class name for your MIDlet.

3) Most helpfully, the tool builds a complete directory structure for you in the "apps" directory within the toolkit home. It makes *everything* you need, and even tells you where to place your source file.

4) Open your editor and type in a little MIDlet (a class that extends MIDlet). These are tiny little things, mostly, with lifecycle callbacks that work much like applets. There are plenty of examples that come with the toolkit. Be sure to name the class with the name that you specified when you created the new project.

5) Click the Build button. Really. That's it. It compiles your little MIDlet and (assuming you don't get compiler errors) it's ready to run.

6) Click the Run button. Up pops the default, garish-yet-somehow-stylish emulated phone. You'll see your project name and a "launch" button. Select the "launch" button and there you go! Wow!

7) Oh, you made a mistake and it doesn't work correctly? No worries. Change your source code, hit "save" in your editor, and click Build again. It really is that simple. Geez. Compare this to the steps to try even the simplest bean or--these days--even a simple web application requires some effort to configure and deploy into Tomcat correctly. Yes, we have Ant scripts for everything, but there's just a hundred and one picky little things that can always get you, especially when moving to a new machine, new version of Tomcat, etc. But this Wireless Toolkit, well, like I said--instant gratifcation.

The best news today seems to be that most developers doing MIDP development *are* in fact doing games. Small games. That means that some lucky folks are doing real-world development where you can have a complete product built and delivered in a week or less. Yeah, there are plenty of headaches for those doing real deployment, but these Java-enabled devices finally *are* starting to appear now, even in the US, in a Big Way. (Sure, 2.5 years after it was announced at JavaOne that these days were just around the corner, but still. It HAS finally happened.) And MIDP 2.0 support can't be *that* far behind.

So if you just want to have some fun, and who knows -- maybe soon you'll have a chance to work full-time or even just on the side on some little mobile device games--download the Wireless Toolkit and play. It's the least painful New Java Thing To Learn that I can think of, and it'll help you get your simple game chops back. Lunar Lander. Asteroids. You *know* you used to make those things when you were *really* supposed to be studying for midterms...

Besides, *small* things are now culturally popular. There's the Mini Cooper. The new iPod Mini. And there's Mini Java. (Yeah, yeah, I know it's MICRO, but "mini" is cooler.) So I'm now unofficially insisting that J2ME is Java 2 Mini Edition.

Related Topics >>