Skip to content


Creating a BlackBerry app - MIDP or BlackBerry CLDC?

I’m going to take a break in this post from my usual hands-on tutorial approach to write a little bit of an editorial piece, and try to provide answer for a question that I hear a lot: When developing for BlackBerry, should you build MIDlets, or BlackBerry J2ME CLDC applications?

(Hint: The answer is CLDC applications. Read on for the reasoning)


Would-be BlackBerry developers have a choice, even before they start building an application. Should you build your app as a MIDlet, or as a ‘native’ BlackBerry J2ME application (what RIM calls a CLDC application)?

MIDlet vs CLDC

The terminology can be confusing, so quickly:
MIDP
Java ME (Java Platform, Micro Edition) (formerly J2ME), is the mobile version of the Java platform. It’s a stripped down version of Java SE (Java Platform, Standard Edition) which most Java developers are probably familiar with. Java ME comes in different configurations, and on top of each configuration there are different profiles available. What’s commonly called J2ME (or sometimes MIDP) is actually the Java ME Connected Limited Device Configuration (CLDC) with the http://en.wikipedia.org/wiki/Mobile_Information_Device_Profile. Applications built using MIDP are called MIDlets - a naming analogue with Applets or Servlets. So you might guess that this means the application lifecycle bits of a MIDlet are defined in the MIDP portion of the JavaME/CLDC/MIDP stack - and you’d be correct. CLDC itself defines some stripped down versions of core Java SE packages (lang, util, io) as well as some basic language features. MIDP defines a whole bunch more stuff, including GUI, more IO, and - yes - application lifecycle.

BlackBerry CLDC
The BlackBerry can run MIDlets just fine - it implements the full CLDC/MIDP (the latest versions of both, if you’re curious). But it also implements its own application framework, GUI framework, and a lot of other functionality. RIM’s term for a BlackBerry application built using their application framework is CLDC Application.

MIDlet vs. CLDC Application

There are many differences between the two types of application. I’ll highlight what I think are the most important ones, and point out areas where there isn’t really a difference.

Lifecycle

CLDC Applications have more flexibility in their lifecycle than MIDlets do - at least on BlackBerry. Specifically, a CLDC app can start when the BlackBerry starts (or reboots) and it’s easier to get it to run in the background to do listening, processing, etc. For many apps, this means CLDC is your only choice

User Interface

This is the big one. RIM has developed a rich UI library (in Java) for the BlackBerry. It’s designed to take full advantage of the BlackBerry input (keyboard, trackball and touchscreen on the Storm), and provides a lot of pre-built components. I’ve written about it extensively. The MIDP UI library just doesn’t give you the same power. To approach the complexity of a ‘native’ BlackBerry UI requires you to re-do a lot of the work that RIM has already done, and even then there are things you can’t do.

Some specific advantages of the BlackBerry UI library over MIDP (all in context of running on a BlackBerry of course):

  • Rich set of components, managers, screens
  • Access to trackwheel events
  • Easy access to all the BlackBerry keys (including ALT, escape, the softkeys)
  • Ability to provide the appropriate menu depending if the trackball or menu key was pressed
  • Integration of BlackBerry components (the browser, BlackBerry Maps) into a screen in your application
  • Built-in support for localization
  • Accelerometer support for Storm
  • Touch-screen events for Storm
  • Ability to change the homescreen icon

Let me know if there are some I’ve missed.

Things that can be used by a MIDlet or CLDC application

Contrary to what I’ve heard in some places, you can use a lot of the BlackBerry specific APIs in a MIDlet. These include cryptography, invoking other applications (but not embedding their UIs), extended SMS and location based services.

But - the MIDlet you build using any BlackBerry APIs will be a BlackBerry specific MIDlet. It will rely on BlackBerry APIs and so will only be able to run on a BlackBerry. If you’ve already taken that step - I’d ask why not go all the way and get a nicer UI while you’re at it?

A special note - you can, it seems, build a MIDlet for submission to the BlackBerry Application Storefront. However, you’ll have to compile it into a COD file, using the JDE (or Eclipse Plugin).

Possible advantages of going with a MIDlet

The biggest reason organizations want to go with a MIDlet rather than a CLDC application is obvious - you really write once, run anywhere. Now, this is true (barring implementation quirks with MIDP devices to be sure, but for many apps they’re not an issue) - but, you limit yourself to the MIDP lowest common denominator. This means your application doesn’t look or behave quite as nicely as a BlackBerry CLDC application. Think about what a Swing (or any pre-SWT) application looks like vs. a native Windows application and you’ll have some idea.

Maybe for your application it’s not an issue - and if so, more power to you - but from experience if you’re going to target the BlackBerry as the initial platform for your brand-new mobile application (and it’s a very good choice, maybe only iPhone would be better, but with the BlackBerry Application Storefront up and coming, the game will change again) then it’s in your interest to do everything you can to succeed on that platform. If you don’t succeed, supporting MIDP - or any other platform for that matter - might become a moot point.

Common code

There’s a way to mitigate cross platform headaches somewhat. MIDP and BlackBerry CLDC do share a lot in common. Enough so that business logic, and most networking code at least can be almost identical between the two platforms. Smart division of your app and supporting libraries can definitely save work if you want to support MIDP deviced and BlackBerry handhelds.

In the end…

With the BlackBerry Application Storefront launching soon, it’s never been a better time to get into the BlackBerry application market. Hopefully I’ve convinced you to go the CLDC Application route - you’ll save a lot of headache, and end up with a much better application.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Posted in basics. Tagged with , , , , .

6 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Hi, I am not sure where to request this but can you provide some insight into localization for blackberry developers? I posted this on StackOverFlow. Any help is greatly appreiciated.

    http://stackoverflow.com/questions/568079/blackberry-localization-resource-bundle

  2. RC said

    thanks for the information, it answers my question.

  3. Jacob T said

    Very informative, thank you.

  4. Alex said

    Thank you for this article. It helps me to understand MIDlets and CLDC.

  5. BC said

    Very helpful. Thanks!

  6. Mike Lennon said

    What about localization, I would like to suggest you great collaborative localization service crowdin.net that takes the pain of BlackBerry applications translation.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.