This document is not supposed to be a guide for LWUIT [1]. I want to provide some information for interested LWUIT programmers to extend their reach to the BlackBerry and Android platforms. If you have never worked with these targets before, don't forget to read some of the available developer documentation[9,10]. There is way too much important information to put into one place. But this document should help you by giving a working example and providing links to other resources along the way.

I won't go into much detail on how to install and use the required software tools. Please read the documentation that comes with each software and search the Web, or ask for help in a forum [12,13,14]. I assume that you already use an IDE like Netbeans or Eclipse.


Building for Android


You could use Eclipse and the Android plugin for development. If that is your favourite IDE then you are pretty much set after including the LWUIT sources [3] and the implementation classes for Android [4]. I don't know if there is a working plugin for Netbeans users. But you can live without it if you reference the android.jar file of the Android SDK and use an ANT script for building and installation. The demo app archive contains an ANT build script that you could use [5]. Just have a look at the build.xml file. Here are some requirements to make it work:

Apache ANT (not required if you use Netbeans) [6]
Android SDK 2.0 or later[10]

Note that signing your application for Android is mandatory. The good news is that it is free, you can use your own certificates [11].

The ANT file from the demo archive builds your application for Android OS 1.6 and later. It should work on any future device, provided that you design your application to work with any resolution, touch screen or no touch screen, hardware keyboard or not, screen density, ... . LWUIT gives you the tools to do that, it's up to you to use them.
To make it work you will have to configure a few properties at the top of the script. The build process will copy all files into a separate build directory and use the tools from the Android SDK to assemble your application.

In the end you will have an APK file within your 'lwuitdemobuild_android' directory that you can use to install on the emulator or on real devices. The script contains a few ANT targets that can install the app on the device or running emulator. So you don't have to use the commandline tools all the time.


Building for BlackBerry


The LWUIT blog describes in detail how to build LWUIT applications for BlackBerry with Netbeans [17]. That is a very nice step-by-step guide to get going. The implementation classes are part of the LWUIT SVN repository [3].

I used to provide my own implementation (and it can still be found in the LWUIT incubator) but it has not been updated in a while and you really should use the one from Oracle. The following links still provide useful tools if you want to setup automated builds:

bb-ant-tools [7]
Antenna [8]
SUN WTK 2.5.x [16]
BlackBerry JDE. (You probably don't want to mess with anything below 4.7 any more) [9]



If you want to discuss this, have questions or suggestions please post your comments to the LWUIT forum [12].


Links


[1] LWUIT Homepage - http://lwuit.java.net
[2] LWUIT Blog - http://lwuit.blogspot.com
[3] LWUIT Subversion Repository - http://java.net/projects/lwuit/sources/svn/show
[4] LWUIT-Incubator Subversion Repository. Android implementation in 'thorsten_s' subdirectory. - http://java.net/projects/lwuit-incubator/souces/svn/show/
[5] Sample application and build script for Android. - http://www.pader-sync.com/LWUITDemo.zip
[6] Apache ANT - http://ant.apache.org/
[7] bb-ant-tools ANT extension. - http://bb-ant-tools.sourceforge.net/
[8] Antenna ANT extension. We only use the preprocessor. - http://antenna.sourceforge.net/
[9] BlackBerry JDE downloads. - http://na.blackberry.com/eng/developers/javaappdev/javadevenv.jsp
[10] Android SDK and developer resources. - http://developer.android.com/
[11] Signing Android applications. - http://developer.android.com/guide/publishing/app-signing.html
[12] LWUIT Development Forum. - http://forums.java.net/jive/forum.jspa?forumID=139
[13] BlackBerry Forums. See the 'Development' section. - http://supportforums.blackberry.com/
[14] Android Developer Forums. - http://developer.android.com/community/index.html
[15] BlackBerry knowledgecenter article about the different JDEs and compatibility. - What_Is_-_Appropriate_version_of_the_BlackBerry_JDE.html
[16] SUN's Wireless Toolkit. - http://java.sun.com/products/sjwtoolkit/
[17] LWUIT blog entry on how to build LWUIT apps for BlackBerry. - http://lwuit.blogspot.com/2009/11/building-project-on-blackberry.html