Home > Articles > Programming > Java

J2ME MIDP Deployment Services

📄 Contents

  1. An Introduction to the MID Profile
  2. The Client Side
  3. The Server Side
  4. Conclusion
This article introduces you to MIDP deployment. You learn how it works with a concrete example; and there is also a discussion about the other parts (client, reusable class, and server side) of such an example.
This article is derived from Java Deployment with JNLP and WebStart (Sams, 2001, ISBN: 0672321823), by Mauro Marinilli.
This chapter is from the book

When facing the problem of porting Java to the myriad of handheld and dedicated devices that constitutes the new wave of portable devices while preserving the advantages of the Java platform (portability, security, with an high-level language—widespread among developers), Sun engineers have devised a particular architecture, composed of few configurations for defining the common features for a class of devices (they comprise the virtual machine, core libraries, and some APIs) while leaving the differences of each device described by a so-called profile.

Profiles are thought of as gathering together not only common devices (such as mobile phones, for example), but also common applications.

The two configurations currently provided for the J2ME platform are the following:

  • Connected Limited Device Configuration (CLDC). This configuration is for devices with constrained hardware resources (principally CPU and memory). Typically, such devices run on either a 16- or 32-bit CPU with 512 Kbytes or less memory available for client applications and the Java platform itself.

  • Connected Device Configuration (CDC). Essentially, this configuration is designed for next- generation devices with more robust resources than CLDCs. Typically, these devices run on a 32-bit CPU, and have at least 2 Mbytes of RAM totally available for the Java platform and client applications.

A need among device manufacturers is the capability to dynamically change the features provided by the device. That is to say, the software is not hard-coded within the device once and for all, but could be to some extent dynamically loaded. Here, deployment techniques come into play.

The configurations don't address lifecycle issues (installation, launching, and removal), leaving these and other features to their profiles. Therefore, we are obliged to discuss deployment issues on a per-profile basis. The following section discusses the deployment of the Mobile Information Device Profile (MIDP).

Deploying MIDlets

The Mobile Information Device Profile (MIDP) is a set of Java APIs that, together with the Connected Limited Device Configuration (CLDC), provides a complete J2ME application environment defining issues such as user interface, the application model, networking, and persistence storage for mobile devices such as cellular phones and the so-called two-way pagers.

The code proposed here was developed and executed on the J2ME Wireless Toolkit from Sun, available at http://www.javasoft.com/products/j2mewtoolkit/.

The key component in the deployment of MIDlets is the Java Application Descriptor (JAD) file that describes all the deployment-related details for a MIDP executable.

Application Descriptor Files

An application descriptor file is a text file, encoded with Unicode, with the suffix .JAD. It is made up of text lines composed as follows:

[attribute-name]+': '+[value]

Such attributes can be read by MIDlets using the static method MIDlet.getAppProperty. Listing 1 shows an example of a JAD file.

Listing 1 An Example Of a Java Application Descriptor (JAD) File

MIDlet-Name: MIDletApplication
MIDlet-Version: 0.0.1
MIDlet-Vendor: myself
MIDlet-Jar-URL: http://www.awebsite.biz/apps/app.jar
MIDlet-Jar-Size: 1234
MIDlet-Data-Size: 256

Attributes in a JAD file can be divided into two main groups, depending on whether they are required or not. Note that attributes beginning with MIDLet- are thought to be "system" attributes, and are reserved. Application-specific attributes cannot begin with the MIDlet- prefix.

Required attributes in every JAD file are the following:

  • MIDlet-Name. Specifies the name of the application that will be shown to the user.

  • MIDlet-Jar-URL. The URL from where the JAR file can be downloaded.

  • MIDlet-Version. The MIDlet version.

  • MIDlet-Vendor. The MIDlet vendor.

  • MIDlet-Jar-Size. The size of the JAR file

Optional attributes for JAD files:

  • MIDlet-Data-Size. The minimum number of bytes of persistent data required by the MIDlet. The device should ensure this memory to the application to be run, whereas it can provide optionally more.

  • MIDlet-Description. A brief description for the user.

  • MIDlet-Info-URL. A link to the application home page.

  • MIDlet-Icon. An icon that (depending on the particular device) will be associated with the application. The PNG image file format is used.

  • Application-specific attributes, used to configure the MIDlet via its JAD file. For example, the following line in a JAD file would indicate to the MIDlet to launch the configuration property:

    prompt-user-at-startup: true

Other attributes (such as MicroEdition-Profile and MicroEdition-Configuration) together with some of those presented above can be specified in the JAR file itself as an entry in the MANIFEST.MF file.

Now that we have seen the main details of the deployment of MIDP-compliant executables, we will see a complete example of a custom advanced deployment service. Such a service is provided to client MIDlets via an HTTP-based, client-server architecture. We will begin with the client.

An Example

We will show an example of a MIDlet application deployment that uses some extra deployment services; in this case, a license utility for registering unlicensed copies of the software. The application is deployed on the client wireless device, thanks to the JAD file shown in Listing 2.

Listing 2 The Application Descriptor for Our Application

MIDlet-1: zmid, /splash.png, com.marinilli.ZMIDLet
MIDlet-Jar-Size: 7296
MIDlet-Jar-URL: zmid.jar
MIDlet-Name: ZMIDLet
MIDlet-Vendor: Maurosystems
MIDlet-Version: 1.0

The application class source is shown in Listing 3.

Listing 3 The ZMIDLet Class

package com.marinilli;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
 * Chapter 5 - A Sample MIDlet
 * @author Mauro Marinilli
 * @version 1.0

public class ZMIDLet extends MIDlet implements CommandListener{
 private List mainList;
 private MIDLicenseManager licenseManager;

  * Constructor
 public ZMIDLet() {
  licenseManager = new MIDLicenseManager(this);

  * Invoked when the MIDlet is paused
 protected void pauseApp() {

  * for cleaning up resources
 protected void destroyApp(boolean b) throws MIDletStateChangeException {
  licenseManager = null;
  mainList = null;

  * To launch the MIDlet
 protected void startApp() throws MIDletStateChangeException {
  mainList = new List("Select a Number",
              new String[] {"Option 1","Option 2","Option 3","Register"},


  * handles user commands
 public void commandAction(Command c, Displayable d) {
  int pos = mainList.getSelectedIndex();
  if (pos==3){

  try {
   show("Hello!", "OK?");
  catch(Exception err) {
   show("Error", "general exception");

  * utility method to show modal alerts
 private void show(String title, String txt){
  Alert a = new Alert(title);


In Listing 3 (lines 41–49), the MIDlet is started with the standard startApp method, prompting the user with a list of options (the MIDlet main menu). The commandAction method (lines 54–66), similar to the actionPerformed method, handles user commands from the option list (as it registered for at line 48). Some methods pertain the MIDlet lifecycle, such as pauseApp, destroyApp, and startApp.

Only the "register" option triggers a real action (it activates the license registering form in line 57), whereas all other options will show a fake message (line 61). The show method at lines 71–76 simply shows a full-screen message until the user explicitly closes it.

When launched via the Sun MIDlet emulator, our simple program opens up, showing an option list, as shown in Figure 1.

Figure 1 The sample application at work.

When the user selects the registration option, the MIDLicenseManager is invoked (line 57 in Listing 3) for starting the registration procedure, whose menu is shown in Figure 2.

Figure 2 The user requests to register its copy.

Note that the MIDLicenseManager class is general-purpose and not bound to the particular application code used for launching it. See below for a discussion of this class.

Getting back to the MIDlet interaction—after the user fills in the registration form, the data is sent (wirelessly or with other device-dependent types of connection) to a Web server, where it is evaluated. If the license id and password are valid, a positive response is returned to the MIDlet and the message shown in Figure 3 is shown to the user.

Figure 3 The response of the registration procedure.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020