Developed by Research In Motion (RIM), the BlackBerry is a handheld wireless device whose major selling feature to date has been instant, secure, mobile access to email. New BlackBerry devices support voice communications as well. While some BlackBerry devices are based on C++, many new ones support the Java 2 Platform, Micro Edition (J2ME), primarily because Java technology makes developing applications so much easier. Its platform-independence eliminates many porting woes and its automatic garbage collection lets developers concentrate on application logic rather than memory management. RIM's support for J2ME includes development of its own Java virtual machine (JVM)1, which supports the Connected Limited Device Configuration (CLDC) and the Mobile Information Device Profile (MIDP). BlackBerry devices also come with additional BlackBerry-specific APIs, however, that enable developers to create applications that have the BlackBerry-native look and feel, and are more sophisticated than standard MIDlets developed using MIDP. This article describes the BlackBerry architecture and two application models, and gets you started developing applications and deploying them on the BlackBerry. Contents
The BlackBerry Architecture
BlackBerry devices are offered by Nextel, Telus, T-Mobile, and many other wireless carriers. Once a device is on a carrier's network, it's linked to RIM's Network Operating Center (NOC), which has direct connections to all RIM's carrier partners and to BlackBerry Enterprise Servers (BES) deployed all over the world. The BlackBerry Enterprise Server (BES) software is middleware that links handheld devices to corporate email services such as Microsoft Exchange and Lotus Notes, as depicted in Figure 1:
Installed behind the corporate firewall, a BES can be configured with additional services. The Mobile Data Service (MDS), for instance, gives devices access to servers in the corporate intranet that wouldn't be accessible from public networks otherwise. For your BlackBerry to take advantage of such features you must configure it to use a BES when you install the Desktop Software Manager. This manager comes with the BlackBerry, but you install it on a computer connected to the corporate intranet, then connect the BlackBerry to that computer. Encryption keys are generated for secure communication between the device and the BES. On devices that aren't linked to a BES, email integration is achieved through a web-based client. You select the appropriate option when installing the Desktop Software Manager, as in Figure 2.
BlackBerry Application Models
To give developers flexibility in designing sophisticated wireless applications for the enterprise, BlackBerry supports two application models:
BlackBerry Extensions to J2ME
In addition to full support of standard CLDC and MIDP APIs, RIM provides BlackBerry-specific extensions that enable you to develop applications with the look and feel of native applications. The BlackBerry APIs provide tighter integration for BlackBerry devices, and access to BlackBerry features for user interface, networking, and other capabilities.
Generally, you can use CLDC, MIDP, and BlackBerry APIs together in the same application – with the notable exception of user-interface APIs. A single application should not use both the
Unlike MIDP's UI classes, RIM's are similar to Swing in the sense that UI operations occur on the event thread, which is not thread-safe as in MIDP. To run code on the event thread, an application must obtain a lock on the event object, or use Your choices come down to these: You can develop your application as a standard MIDlet that will run on any MIDP-enabled device, or as a RIMlet, a CLDC-based application that uses BlackBerry-specific APIs and therefore will run only on BlackBerry devices. If you're developing solely for the BlackBerry you should use the CLDC model because the RIM APIs will give you the BlackBerry-native look and feel &ndash without denying you the option to use J2ME-standard APIs in areas other than UI. For persistence, you can use BlackBerry's APIs or the MIDP RMS APIs; if you're already familiar with RMS, use it. For networking, use the Generic Connection Framework.
The main class of a RIMlet extends either RIM's Java Development Environment
The BlackBerry Java Development Environment (JDE) is an integrated development environment (IDE) that provides a complete set of tools and APIs for you to develop Java applications that run on BlackBerry devices. JDE requires the Java 2 SDK to run. It comes with a BlackBerry simulator for testing, but I recommend you obtain an actual BlackBerry device. I personally like the 7510 model, a data and voice handheld device for networks that adhere to the Integrated Digital Enhanced Network (iDEN) standard, such as Nextel in the US and Telus in Canada. Other devices run on GPRS or CDMA2000/1x networks. To test your applications you must also sign up with a wireless carrier for a plan that includes data services. You can get voice service as well, of course, but beware: Having both phone and email services in a single appealing mobile device is addictive!
Through the JDE you can compile your Java source code, package it in a The current version of the JDE is 4.1. I've used JDE 3.6 for this article only because the BlackBerry I'm using came with version 3.6 of BlackBerry and I haven't upgraded the OS yet. For a list of the JDE versions available that indicates what OS versions they support, please see the JDE download page. Links to that page and to other resources for developers appear at Java SDKs and Tools. Running Existing MIDlets on the BlackBerry
To run a standard MIDlet on a Java-enabled BlackBerry device, you first need to convert the
You can load the resulting
Once the application is loaded into the BlackBerry, you can run it just as if it were a native application.
You can use
Developing Applications Using the JDE
Recall that BlackBerry applications that support user interaction extend To get started developing BlackBerry applications with the JDE, you create a workspace, and subdirectories for each project. Then you create source files, build the application, and test it, much as in any IDE. Let's walk through development of a simple example. Create a Workspace
Create a Project
Create the Source Files
Once you've entered this code, you can build the project. To compile the source file, perform preverification, and package the application into a
The JDE will generate
Now you can run the application in the simulator. In the JDE's
To load the application into a real device, use the
Deploying Applications Using the BlackBerry Desktop Manager
To deploy the application using the BlackBerry Desktop Manager, you need to generate an
Now you can use the BlackBerry Desktop Manager and a USB cable to load the
RIM's Extensions to JAD Files
The JDE generated the following JAD file for the
As you can see, this Some of RIM's JAD properties are required, others are optional. Here are the required properties:
The optional properties are:
Deploying BlackBerry Applications Over the Air
You can download both standard MIDlets and BlackBerry-specific applications applications over the air, wirelessly. The provider puts up on a server both a To enable you to download standard MIDlets to a BlackBerry, the Mobile Data Service feature of the BES provides a built-in transcoder that converts Be aware that you can download a Conclusion
RIM's BlackBerry handheld devices are becoming quite popular for both data and voice, and wireless carriers all over the world are distributing them. Several BlackBerry devices are Java-enabled, supporting CLDC and MIDP, while also providing API extensions for BlackBerry-specific features. The BlackBerry Java Development Environment enables developers to create CLDC-based, BlackBerry-specific applications that will run only on a BlackBerry, as well as standard MIDlets that will run on any MIDP-enabled device, including those bearing the BlackBerry brand. This article provided an overview of the BlackBerry architecture, and a tutorial on developing J2ME applications for the BlackBerry. The sample code gave a flavor of the CLDC-based BlackBerry programming style. The article described how to load existing standard MIDlets into a BlackBerry, as well as how to download applications over the air. For more information
Acknowledgments
Thanks to RIM and Telus Mobility for lending me the devices I used to deploy, run, and test Java applications for this article. Also, special thanks to Roger Riggs of Sun Microsystems, whose feedback helped me improve this article. About the author
Qusay H. Mahmoud provides Java technology consulting and training services. He has published dozens of Java articles, and is the author of Distributed Programming with Java (Manning Publications, 1999) and Learning Wireless Java (O'Reilly, 2002). 1As used in this document, the terms "Java virtual machine" or "JVM" mean a virtual machine for the Java platform. | |||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||