Wednesday, April 21, 2010

Build LWUIT BlackBerry CLDC application

Last week finally I have time to review the Shai's blog  about building LWUIT project on Blackberry platform. At first I tried to follow the step by step in his article, but I am  disappointed because of so many errors of his build.xml. After a couple hours fix, I still could not make the build, so I decided to give up Shai's script, and choose an easier way.
My solution is just using NetBeans and BlackBerry JDE, it is much easier to build a demo.
Here is the step by step description:

Build LWUIT BlackBerry library
1. Checkout the LWUIT source code from SVN, (, the LWUIT source includes the NetBeans BlackBerry port project.
2. Install JDE 4.7 and Configure BlackBerry support in NetBeans, you can follow this link to configure;
3. Start NetBeans, open the "BlackBerryPort" poject under the "BlackBerry" sub folder of lwuit project source, there are two configuration for this project, the default is for non touch screen build, the "touch" configuration is for touch screen device like STORM.for non touch device, just choose DefaultConfiguration, build the project, you will see BlackberryPort.jad and BlackberryPort.jar in \dist folder, they are the LWUIT library for BlackBerry devices;

Build LWUIT Demo into BlackBerry CLDC application
1. Open Blackberry JDE, create a new workspace, called "lwuitdemo.jdw";
2. add a new project under the workspace, name it "lwuit",  choose its Application type as "Library", import the BlackberryPort.jad and BlackBerryPort.jar file into the project. then build it, the JDE will generate lwuit.cod and update BlackBerryPort.jad file.  
3. download LWUIT 1.3 from sun website, it comes with the famous LWUITDemo source code, open the LWUITDemo project using NetBeans, build it;
4. add another new project in the JDE workspace, name it "lwuitdemo", choose application type as "CLDC Application";
   set up the correct value with title, version and Vendor information;
   next you need to add project dependency to "lwuit" project, right click project, choose "Project Dependencies..", choose "lwuit project";
   copy all the java source code from LWUITDemo src folder, add them into the project, ignore those png files and .res files;
   go to  build\preverified folder, copy all the png files and .res files, add them into your JDE project;
   right click icon.png, choose "use as application icon";
5.Modify the
Made following changes:
make sure the UIDemoMIDlet extends from uiApplication, like this:
public class UIDemoMIDlet extends net.rim.device.api.ui.UiApplication  {...}
Add the following methods, copied from Shai's blog:
public static void main(String[] argv)
        new UIDemoMIDlet().startApp();
    public void notifyDestroyed()
    public void platformRequest(String s) {
In startApp() method, comment out the following statement, because non touch device need to disable the virtual keypad:
// VKBImplementationFactory.init();
6. Build the lwuitdemo project.
7. Sign both lwuitdemo.cod and lwuit.cod fle, load them both into your blackberry device.
8. If you want to provide OTA download, that is a litttle bit tricky:
   You need to download two artifacts, one for lwuit libray, the other for lwuitdemo, which means user need to download two links:
   1) lwuti library:
   2) lwuitdemo application:

You can download the whole source code of the JDE project from here.

In future I would like to share:
  1. Provide an updated build.xml based on Shai's blog;
  2. provide how to build LWUITDemo MIDlet project for BlackBerry device.


  1. Hi Steve, This is really helpful,Thanks,
    everything compiles successfully, just have a problem when running the app, im using the blackberry 9500 Simulator with the JDE 4.7, i get the "error in constructor" Exception, i assume there is no compatibility issues? also, i have not changed my build.xml at all..
    please help

  2. Hi Steve...
    I'm trying to port my JME LWUIT application to BB, and I was using your article.
    However I'm running into some problems. I tried to download the source code of the JDE project, however the resource is not reachable.
    Can you provide an updated link please?

    Thank you anyway for these articles regarding BB port of LWUIT.

    Tiago Clemente

  3. Hi, CastSpellar,
    I attached the source code in my email to you. Please let me know if you still have issues.

  4. Hi, Ryan,

    Could you attach your source code? Or can you build my code successfully in your computer?
    If you don't mind, you can send me email with your code.

  5. Hi Steve,

    "You can download the whole source code of the JDE project from here."

    This link is no longer working, can u please update and share the new project folder.

  6. Hi, Shankar,
    Thanks for your remind, I just change the share setting, now it should be OK.

  7. Thanks Shankar to share this article with us. M also working with Blackberry Application Development, so this is very helpful to me.

  8. Hi, Ryan,
    I remembered that this project is for blackberry non-touch device build, if you want to use in 4.7, you need to use the different jad and jar file of lwuit blackberry port

  9. This comment has been removed by the author.

  10. Hi,

    I just wanted to say that I really enjoyed your blog and this post. You make some very informative points. Keep up the great work!

    Blackberry development

  11. Hi, I managed to get my LWUIT midlet workign on the BB emulator using parts of this technique you describe - unfortunately I found your instructiosn to be out of date (there is no Blackberry port project in the lwuit source for example, Im presuming its now called UI_RIM?).. Anyway it runs and works but when I try to go back for instance I presume I need to use the BB menu key? However when I press this key a menu does appear but it is empty, nothing in it at all. Im assuming in here I should see the softkey equivalents from the j2me version? but nothing, if I select the menu I get a null pointer. Any tips about how to populate this menu or what my problem might be would be greatly appreciated. Thanks very much for your useful guide!!

  12. Hi, Gaz,
    this post is almost a year old, I just noticed that the latest version of LWUIT project has changed, you are right, they use UI_RIM instead.
    I would suggest use NetBeans IDE to build the blackberry application.

    I just browse the the UI_RIM, they use Blackberry native menuItem API, it should be no problem. For your case could you send me your source code, so that I can point out the issue.

  13. Hi, I have built my midlet for Blackberry Storm, and it runs on the emulator - but I cant touch things to select them, on the emulator im still having to use the cursor keys to move around and enter to select things - how do I get it so I can simply touch something and it will select? Do I need to turn on touch somehow? Thanks!

  14. my app is working fi9, bt it shows default app icon and midlet name instead of app icon and application name? please help me?

  15. Hi Steve,


    I have blackberry 8700, and i installed spy cell phone software on my blackberry, but when i use to run the application, it gives an error saying "java.lang.NoClassDefFoundError"

    Can any one help how to get rid of this error?