Advertisment

OTA Provisioning with J2ME

author-image
CIOL Bureau
Updated On
New Update

Eric Giguere

Advertisment

The complete application development cycle for the Mobile Information Device Profile (MIDP) environment involves more than just coding and debugging your applications. It's also vital to deploy your application in a way that makes it easy for a user to download and install it, in a process called provisioning. If your application is hard to acquire and install, it won't be a success.



While developers are comfortable with using a serial or USB connection to download applications to a wireless device, most users don't have the equipment or the skills to do the same. Users want to download applications wirelessly, the same way they send and receive messages or browse the Internet. This ability is referred to as over-the-air user-initiated provisioning, OTA for short.

Advertisment


OTA for MIDP devices was first described in an addendum to the MIDP 1.0 specification, although technically it was not part of the specification itself but just a recommendation by the MIDP 1.0 expert group. This addendum was revised and formally incorporated into the MIDP 2.0 specification. To be MIDP 2.0-compliant, devices must support OTA provisioning, so now is the time to make sure your MIDlets are properly packaged for wireless installation.



Advertisment

The easiest way is to use the J2ME Wireless Toolkit, which incorporates a small provisioning server that emulates a production OTA environment. Available in version 2.0 Beta 2 and later versions of the toolkit, this nice feature enables you to get an idea of whether a server will provision a device with your application successfully without the hassle of setting up and configuring a local web server to act as an OTA server. Some MIDP 2.0 features - like the push registry - are available only to applications downloaded via OTA. If your application uses those features, the built-in OTA server is a critical tool of the development process.



To use the OTA server, start the KToolbar application and open an existing project such as the demos project that ships with the toolkit. Instead of clicking the Run button on the toolbar, choose the Project menu, then the Run via OTA item. The emulator starts, but does not immediately open the MIDlet suite to let you select which MIDlet to launch. Instead, the emulator launches its application management software (AMS), the system software that manages the installation and removal of MIDlet suites. At the same time, KToolbar activates its built-in OTA server. Click the Apps button on the emulator to activate the AMS.

Advertisment


The AMS's main screen lists MIDlet suites already installed - there will be none the first time you run it, of course. At the top of the list is an item labeled Install Application. Select this item, click the Menu button, and choose Launch from the menu to start the application installer. The installer prompts you for the URL of an HTML file containing a link to the MIDlet suite's Java application descriptor (JAD). KToolbar automatically generates this HTML file for you, placing it in the project's bin directory, and initializes the installer with its URL, which will look like this:



Advertisment

http://localhost:1364/demos/bin/demos.html



The first part of the URL is the address of KToolbar's OTA server, which is really just a stripped-down web server. The URL may differ from this example. The installer doesn't care what it's connecting to - you can change the URL if you want to test the installation process from an actual web server, for example.

Advertisment


Click the Menu button and select Go to start the installation process. The installer fetches the HTML file and parses it, looking for links ending in .jad, the standard extension for JAD files. If there are multiple links, it prompts you to choose the one you want. The installer then downloads the JAD file, displays the MIDlet suite's size, version, and vendor, and asks you to approve installation of the suite.



Advertisment

Once you confirm you want to proceed, the installer fetches the suite's JAR file. The JAR file's location comes from the MIDlet-Jar-URLproperty in the descriptor. By default, this value is a relative URL like demos.jar, although when you actually deploy your own application you must change this to the absolute URL of the provisioning web server; for example, http://www.mycompany.com/downloads/demos.jar . After downloading the JAR file, the installer verifies the contents of the MIDlet suite, prompting the user to confirm any permissions the suite requires in order to run. After the verification process is complete, the application is installed and is ready to run.





The J2ME Wireless Toolkit simplifies OTA testing, but eventually you'll need to test provisioning of actual devices from an actual web server. You'll need to deploy your application on a public server, one that is accessible to the general Internet population, and the server will need to be configured with the following MIME type mappings: the .jad file extension must map to the text/vnd.sun.j2me.app-descriptor type and the .jar extension to the application/java-archive type. Note that versions 4.0 and higher of the Tomcat server already include these mappings in their conf/web.xml files.





Once the server is properly configured, place the application descriptor and the MIDlet suite on the server and create an HTML page with a link to the JAD. You may also need to create an equivalent WML or XHTML page for microbrowser users - some devices may allow OTA provisioning to be initiated directly from a microbrowser instead of indirectly, through the AMS.



Before attempting to install the application on your device, however, test it with the toolkit's emulator. You can launch the emulator in provisioning mode directly, by using the OTA Provisioning item in the J2ME Wireless Toolkit 2.0 folder. Then follow the steps described above, supplying the appropriate URL. Once you've verified that things are working in the emulator, try it on an actual device.





About the Author:

Eric Giguere is a software developer for iAnywhere Solutions, a subsidiary of Sybase, where he works on Java technologies for handheld and wireless computing. He holds BMath and MMath degrees in Computer Science from the University of Waterloo and has written extensively on computing topics.
tech-news