KICK START J2ME(tm) Development with BlackBerry(r)
If you are looking to expand your user base, you may want to consider looking into porting your game or application to the BlackBerry handsets. With over one million units sold by RIM, I am sure there is immense potential to increase your user base and profit. Fortunately for us, BlackBerry supports Java and, more specifically, J2ME. The remainder of this article briefly introduces you to development on BlackBerry and some of the differences compared to developing J2ME applications on mobile phones. There is an assumption you have developed with J2ME, are using an IDE such as Eclipse, and already have an understanding of mobile development in general.
First of all, RIM provides their own IDE, called the Java Development Environment (JDE). It comes with a development environment (debugger, context sensitive help, and so forth), e-mail simulator, device simulator, and Internet gateway simulator. The IDE itself is similar to any other IDE you've probably used in the past, such as Eclipse, JBuilder, or Sun One (Forte). Both the e-mail simulator and Internet gateway simulator are used to simulate an enterprise environment. One thing I found extremely helpful is the capability of debugging directly with an actual device via USB. The JDE currently supports MIDP 1.0 and CLDC 1.0. All in all, there is nothing really special here or different from what you are probably used to when developing with J2ME. One additional note: You don't have to use the JDE; you can build .cod files through CLI if you want to continue using build scripts such as ANT and ANTENNA.
JDE in Action
Okay, what are the differences? The JDE produces both the JAR and JAD files, but it also creates an additional file with the extension .cod. This file is needed when deployment is done through OTA. This brings up another point when deploying through OTA: Your server must be configured to support the following file types for BlackBerry:
The JAD file itself contains BlackBerry-specific attributes; the following is an example of what one looks like:
Manifest-Version: 1.0 RIM-COD-Module-Name: MyTestApp RIM-COD-Module-Dependencies: net_rim_os,net_rim_cldc RIM-COD-Creation-Time: 104940394 MIDlet-Jar-URL: unknown RIM-COD-URL: MyTestApp.cod RIM-COD-Size: 15899 MicroEdition-Configuration: CLDC-1.0 MIDlet-Version: 1.00 MIDlet-Name: MyTestApp MIDlet-Vendor: ABC Inc. MicroEdition-Profile: MIDP-1.0
It is probably best to allow the JDE to generate the JAD file and then make the appropriate changes afterwards. Now is probably a good time to mention that, even though your application can be compiled and run when it exceeds 64KB, it is more then likely that users will have difficulties downloading the application via OTA. Breaking down your program into smaller chunks of 64KB or less will solve this problem. A sample snippet of what the JAD file looks like follows:
... RIM-COD-URL-1: MyTestAppLib.cod RIM-COD-SIZE-1: 4039 RIM-COD-URL-2: MyTestApp.cod RIM-COD-SIZE-2: 55540 ...
You will notice that the Lib is defined first; this is required for OTA to work properly. Please consult the JDE user guides on how to create libraries.
Because it is more than likely that BlackBerry users are given a sync cable at the point of purchase, it won't be uncommon for users to install and uninstall applications via USB. In the JDE, there is an option to generate another type of file with the extension ALX. If you open it up, it's nothing more then a XML file.
<loader version="1.0"> <application id="MyTestApp"> <name>MyTestApp</name> <description>MyTestApp</description> <version>1.0</version> <vendor>ABC Ltd</vendor> <copyright>Copyright (c) 2004 ABC Ltd</copyright> <fileset Java="1.0"> <files>MyTestApp.cod</files> </fileset> <application id="MyTestAppLib"> <name>MyTestAppLib</name> <description></description> <version>1.0</version> <vendor>ABC Ltd</vendor> <copyright>Copyright (c) 2004 ABC Ltd</copyright> <fileset Java="1.0"> <directory></directory> <files>MyTestAppLib.cod</files> </fileset> </application> </application> </loader>
The .alx file, along with the .cod files, is needed if installation is done via cable.
Like most manufacturers, RIM provides its own set of libraries. To name a few, they are encryption components, push capability with the use of the BES (BlackBerry Enterprise Server), and enhanced GUI widgets. You should consult their user guides and the Java doc for more information. The main question here is whether you can mix the two. In short, the answer is no; once you start using the core framework provided by RIM, you cannot mix it with the regular J2ME libraries. However, I did find it possible to use pure MIDP/CLDC libraries and call certain packages specific to RIM, such as sound and vibration. You will have to do some experimenting here yourself. The second question related to this topic is portability, of course. If you decide to use the rich RIM libraries, you may find it increasingly more difficult to port your application to another handset.