RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Tackle Device Fragmentation with NetBeans and the NetBeans Mobility Pack : Page 2

Building J2ME applications with a single code base that deploys to an ever-growing set of platforms is a tough and maybe impossible task. Find out how using Sun's NetBeans IDE with the NetBeans Mobility Pack can help.

Exploring NetBeans Project Configurations
Figure 1. Opening the StockQuote Project: After unzipping the contents of the zip file associated with this article, bring the StockQuote project into NetBeans by using the Open Project option under the File menu.

If you have not installed or used the NetBeans IDE, please refer to this article, posted on DevX this summer, in order to get started with NetBeans and the NetBeans Mobility Pack. Once familiar with NetBeans and the Mobility Pack, the code associated with this article and information below can help you write an application to reduce your device fragmentation issues. The operative word here is "reduce," not eliminate—more on this later.

The application provided with this article is a simple stock and mutual fund price quote J2ME MIDlet suite. It will help demonstrate the ability of NetBeans and the Mobility Pack to provide some device fragmentation relief. To get the application working, download and unzip the contents of the source code file onto your file system. It will create a StockQuote folder wherever it is unzipped. Next, start NetBeans and use the "Open Project" feature in NetBeans (as shown in Figure 1) to locate the StockQuote folder and import the project into the IDE.

Examine the project in NetBeans and you should find one of the MIDlets in the suite is RequestQuoteMidlet. This midlet obtains the latest stock or mutual fund price from a financial Web site and stores it into a J2ME record store (see Figure 2).

The second MIDlet in the suite, HistoricQuotesMidlet (see Figure 3), displays the previously stored price quotes for a stock or fund.

Figure 2. RequestQuoteMidlet: RequestQuoteMidlet allows users to enter a stock or mutual fund symbol and obtain, via wireless connection to the Web, its current price which it stores in a record store for later retrieval.
Figure 3. HistoricQuotesMidlet: Using the HistoricQuotesMidlet, previously obtained stock or mutual fund prices, obtained through RequestQuoteMidlet, are displayed in a chart.

Simple enough, but let's assume you want to make this application available to three J2ME-enabled mobile devices. The devices share some features and characteristics, but each offers fragmentation issues. Table 1 below specifies the major differences of the devices and how they relate to the application.

Device A – older J2ME Phone

Device B – new J2ME Phone

Device C - PDA

Supports MIDP 1.0/CLDC 1.0 and therefore cannot use floats for price information.

Supports MIDP 1.1/CLDC 1.1. Can use floats for prices.

Supports MIDP 1.1/CLDC 1.1. Can use floats for prices.

Smaller screen and able to display only a limited number of quotes.

Also has a smaller screen to display only a limited number of quotes.

Larger screen to display more quotes and graphics.

Has no sound to audibly inform users when a stock quote has been retrieved from the Web.

Has sound (MMAPI support) to provide audible indication to users that a price has been retrieved.

Has no sound to audibly inform users when a stock quote has been retrieved from the Web.

Does not require obfuscation.

Does not require obfuscation.

Obfuscation required. The class files on the device are more accessible and therefore vulnerable to reverse engineering, etc.

Table 1. Stock Quote Device Fragmentation Issues: Even with a simple application such as that represented in the StockQuotes MIDlet suite, a number of device fragmentation issues as shown in this table can arise.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date