ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

The Mobile Information Device Profile and MIDlets, Part 2
Pages: 1, 2, 3

MIDlet Packaging

MIDlets need to be properly packaged before they can be delivered to a device for installation. The MIDlet subclass that acts as the main entry point for the MIDlet, together with any other classes that it requires (apart from those provided by MIDP itself) and any images or other files to which it needs access at runtime, must be built into a single JAR file. Packaging information that tells the device what is in the JAR must be supplied in the JAR's manifest file. Similar packaging information is also provided in another file called the Java application descriptor (or JAD file for short), which is held separately from the JAR. A JAR may contain more than one MIDlet, in which case all the MIDlets are deemed to be in the same MIDlet suite. To put the same thing another way, all MIDlets that are in the same MIDlet suite must be packaged in the same JAR.



Both the manifest file and the JAD file are simple text files in which each line has the form:

attribute-name: attribute-value

The name and value are separated by a colon and optional whitespace. All the attributes that are of relevance to the installation of MIDlets have names with the prefix "MIDlet-". A complete list of these attributes, together with a short description of their associated values, can be found in Table 3-2. The values in the JAR and JAD columns indicate whether the attribute is mandatory (M), optional (O) or ignored (I) in the file corresponding to that column.

Table 3-2: MIDlet Packaging Attributes

Attribute Name

JAR

JAD

Value and Meaning

MIDlet-Name

M

M

The name of the MIDlet suite packaged in the JAR file. This name may be displayed to the user.

MIDlet-Version

M

M

The version number of the MIDlet suite packaged in the JAR file. Version numbers take the form a.b.c (for example 1.2.3), where larger values in each field indicate a newer version, with the leftmost field taking precedence. For example, version 1.2.5 is taken to be more recent than version 1.2.3, and, similarly, version 2.1.5 is newer than 1.3.7.

MIDlet-Vendor

M

M

The name of the MIDlet suite provider. This is free-form text that is intended for display to the user.

MIDlet-n

M

I

Attributes that describe the MIDlet in the MIDlet suite. The value n is replaced by a numeric value starting from 1 to identify individual MIDlets. The format of the value associated with this attribute is described in the text.

MicroEdition-Profile

M

I

The version or versions of the MIDP specification that the MIDlets in this suite can work with. Where more than one version appears, they must be separated by spaces. The versions specified are compared to those listed in the microedition.profiles property of the target device to determine whether the MIDlets are compatible with them. MIDP-1.0 is a typical value for this attribute.

MicroEdition-Configuration

M

I

The J2ME configuration required by the MIDlets in this suite. This value is compared to the target device's microedition.configuration property to determine compatibility.

MIDlet-Description

O

O

A description of the MIDlet suite intended to be displayed to the user.

MIDlet-Icon

O

O

An icon that may be used to represent the MIDlet suite during or following installation. The icon must be a Portable Network Graphics (PNG) file.

MIDlet-Info-URL

O

O

The URL of a file that contains further information describing the MIDlet suite. The content of this file may be displayed to the user to allow the user to decide whether to install the MIDlet suite.

MIDlet-Data-Size

O

O

The minimum amount of persistent storage that this MIDlet suite requires. This refers to space used for the long-term storage of data used by the MIDlet suite, not the space required to install and manage the MIDlet suite itself. It is specified in bytes. If this attribute is not supplied, it is assumed that the MIDlet suite does not require persistent storage. Whether or not MIDlets can use more persistent storage space than they initially request is device-dependent.

MIDlet-Jar-URL

I

M

The URL of the JAR file that contains the MIDlet or MIDlet suite described by these attributes. This attribute is used only in the application descriptor.

MIDlet-Jar-Size

I

M

The size of the MIDlet JAR file in bytes. This attribute is used only in the application descriptor.

MIDlet-Install-Notify

I

O

A URL used to report the success or failure of MIDlet installation performed from a remote server. This attribute is not included in the current MIDP specification, but it is supported by the Wireless Toolkit. See the later section "Delivery and Installation of MIDlets" for further details.

MIDlet-Delete-Confirm

I

O

A message to be displayed to the user before the MIDlets are deleted from the device on which they are installed. Like MIDlet-Install-Notify, this attribute is not currently included in the formal specification.

MIDlet-specific attributes

O

O

MIDlet developers can provide limited configurability for MIDlets by including attributes that can be retrieved at runtime.

As you can see, many of the attributes must be supplied in both the manifest file, which resides in the JAR, and in the JAD file, which does not. To see why, it is necessary to understand why two files are used.

Pages: 1, 2, 3

Next Pagearrow