C H A P T E R  3

Tutorial Concepts

In the previous chapter, you installed a MIDP application, called a MIDlet, and executed the packaged application, called a MIDlet suite, which was displayed in an emulator device skin.

This chapter briefly explains the concepts used in this tutorial, such as MIDlets and MIDlet Suites, and how they are applied in the Java Studio Mobility. These concepts are covered only briefly here, but can serve as a quick reference for you. You can find more detailed information on MIDP, CLDC, and other technologies, at the Wireless Developer web site at http://developers.sun.com/techtopics/mobility/.

The topics covered in this chapter are:

MIDP Application Concepts

This section discusses the J2ME technology platform concepts upon which you create mobile applications.

Java 2, Micro Edition (J2ME)

Java 2, Micro Edition is a group of specifications and technologies that pertain to Java on small devices. The J2ME specification covers a wide range of devices, from pagers and mobile telephones through set-top boxes and car navigation systems. The J2ME platform is divided into configurations and profiles, specifications that describe a Java environment for a specific class of device.

Connected, Limited Device Configuration (CLDC)

The fundamental branches of the J2ME plstform are configurations. A configuration is a specification that describes a Java Virtual Machine and some set of APIs that are targeted at a specific class of device.

The Connected, Limited Device Configuration is one such specification. The CLDC specifies the APIs for devices with less than 512 KB of RAM available for the Java system and an intermittent (limited) network connection. It specifies a stripped-down Java virtual machine, called the KVM, as well as several APIs for fundamental application services. Three packages are minimalist versions of the J2SE java.lang, java.io, and java.util packages. A fourth package, javax.microedition.io, implements the Generic Connection Framework, a generalized API for making network connections.

Mobile Information Device Profile (MIDP)

The Mobile Information Device Profile is a specification for a J2ME profile. It is layered on top of CLDC and adds APIs for application life cycle, user interface, networking, and persistent storage.

Structure of a MIDP Application

This section discusses the concepts specific to the MIDP platform.


An application written for MIDP is called a MIDlet. MIDlet applications are subclasses of the javax.microedition.midlet.MIDlet class that is defined by MIDP.

MIDlet Suites

MIDlets are packaged and distributed as MIDlet suites. A MIDlet suite can contain one or more MIDlets. The MIDlet suite consists of two files:

The Java Application Descriptor file lists the archive file name, the names and class names for each MIDlet in the suite, and other information. This file is used by the mobile device to ensure that device has the minimum requirements to run the application.

The archive file contains the MIDlet classes and resource files.

Creating MIDlets in the Java Studio Mobility IDE

Java Studio Mobility is an integrated development environment (IDE), based on the NetBeans development platform, that enables you to use J2ME technologies and add special tools that enable you to code and test J2ME applications, such as emulators and obfuscators.

There are certain concepts used within the IDE that you must know to successfully create applications in the Sun Java Studio environment.

Mounting a Filesystem

A filesystem is comparable to a directory in the operating system. Mounting a filesystem displays the filesystem in the Explorer window, and lets you browse and work with filesystem's files from within the Java Studio Mobility IDE. The mounted filesystem is included in the Java classpath, which is necessary for compiling, running, and debugging code.

Compilation and Preverification

When you compile with the Java Studio Mobility, the tool's MIDP compiler combines into one sequence several steps that might otherwise have to be performed individually. The compiler compiles the MIDlet's .java file and produces a binary .class file.

In the J2SE platform, a bytecode verifier checks the class file to ensure that it meets Java standards and will behave well when executed. However, the code that implements bytecode verification is too large to fit on most mobile devices. Because of the limited memory of mobile devices, bytecode verification for J2ME, CLDC-based applications is broken down into two steps.

In the first step, a MIDlet is preverified, after compilation, to ensure that the MIDlet meets the requirements for the device it is being compiled for. The Preverifier rearranges the bytecode in the compiled classes to simplify the final stage of byte code verification on the CLDC virtual machine, and also checks for the use of virtual machine features that are not supported by the CLDC.

In the second step, classes are verified as they are loaded on the device.

In Java Studio Mobility, the preverification step is completed transparently when you compile or execute your MIDlet. You might never need to know this is happening. However, you should know that the preverification compiler can be set, if necessary, in the Execution properties for that MIDlet.


An emulator lets you simulate the execution of an application on a target device, just as the user might experience it. It gives you the ability to run and debug applications within the IDE. Typically, an emulator includes a sample of devices that it emulates. These sample devices are called skins.

The J2ME Wireless Toolkit Emulator is the default emulator for the Java Studio Mobility IDE. It includes a number of example devices or skins, such as a Default Color Phone and a QWERTY Device. You can test your application on any of the Wireless Toolkit Emulator's example devices. This feature also gives you the ability to test the portability of your application across different devices.

Networked Mobile Data Application

A Networked Mobile Data Application is a client/server application in which the client MIDlet, run on a mobile device, extends an application that exists on a server. The second Currency Converter application in this tutorial is an example of such an example.