Contents Previous Next Index

Chapter   2

Using the midp Executable


The midp command runs a device emulator on your desktop system. You can control many of its runtime characteristics, such as the number of colors that it uses, to better simulate how MIDP will behave when it runs on a device.

This chapter shows you how to use the midp command in the sections:

See Appendix C, "The midp Command” for detailed information in a manpage format.

General Instructions

The midp command is in the midpInstallDir\bin directory. To use the command:

  1. Open a command prompt or terminal window.
  2. Change your current directory to midpInstallDir.
  3. For example, if MIDP Reference Implementation was installed in the directory c:\midp2.0fcs:

    c:\> cd midp2.0fcs 
    
  4. Run the midp command with any commands or options.
  5. The commands and options to the midp command are described below. Using no commands or options starts the emulator and displays the default device skin. See Chapter 1, "Using the Graphical User Interface” for more information. The -help option provides usage information. For example, you could get help with the command:

    c:\midp2.0fcs> bin\midp -help 
    

    The next sections describe some common options.

Improving Device Simulation

The MIDP Reference Implementation uses properties to help the MIDP runtime better simulate the capabilities of a device. For example, by default the MIDP runtime supports multiple color depths. Developers porting MIDP to a device that supports only gray scale can change the value of a property so that the emulator also uses gray scale.

The MIDP configuration properties are stored in two configuration files:

See Appendix C, "The midp Command” for a complete list of the properties in each file. This section covers two topics:

Changing a Property Value

To permanently change a property value, edit the appropriate file. The files have each property name-value pair on a single line. The name and value are separated by a colon, as shown below:

propertyName : propertyValue 

The whitespace around the colon is not significant.

To temporarily change a property value, use the -D command-line option when you run MIDP Reference Implementation. The option has the following syntax:

-DpropertyName=propertyValue 

For example, to have the emulator temporarily use four colors instead of the default 256 colors, you would change the value of the system.display.screen_depth property to 2. You could enter the following command:

c:\midp2.0fcs> bin\midp -Dsystem.display.screen_depth=2 

You can adjust any number of properties from the command line. For example, if you wanted to run installed MIDlet suite number one, simulating a device that had four colors and did not have double-buffering, you could enter the following command:

c:\midp2.0fcs> bin\midp -run 1 -Dsystem.display.screen_depth=2 -Dsystem.display.double_buffered=false 

Common Property Values to Update

It is common to have to update the following property values:

Installing a MIDlet Suite

A MIDlet suite that is both properly packaged and accessible to a web server can be installed on the emulator. It must be accessible to a web server so that the emulator can download it. The URL from which to download and install a MIDlet should be the location of the MIDlet suite’s JAD file. The JAD file contains the URL of the MIDlet suite’s JAR file; that file must also be accessible to the web server.

For example, if the JAD file for the example TicketLand MIDlet suite were available at http://localhost:8080/j2me/midp/games.jad, the following example shows a command that would install it:

c:\midp2.0fcs> bin\midp -install http://localhost:8080/j2me/midp/auction.jad 
Storage name: #Sun%0020#Microsystems%002c%0020#Inc%002e_#Ticket%0020#Auction_ 

If the MIDlet suite is unsigned it will, by default, be put in the untrusted domain. (See "Associating MIDlet Suites and Protection Domains" for more information.) You can change its domain by using the -domain option. The following example shows the unsigned TicketLand MIDlet suite being installed in the trusted domain:

c:\midp2.0fcs> bin\midp -install -domain trusted http://localhost:8080/j2me/midp/auction.jad 
Storage name: #Sun%0020#Microsystems%002c%0020#Inc%002e_#Ticket%0020#Auction_ 

If you use the -install option to install a MIDlet suite that you already have installed on the device, the emulator will replace the MIDlet suite’s code and resources, but by default it will not change or remove any persistent data that the MIDlet suite had stored.

If you want to remove any persistent data written by previous versions of the MIDlet suite, use the -removeRMS option. The following example shows the TicketLand MIDlet suite being installed, and persistent data from previous versions being removed:

c:\midp2.0fcs> bin\midp -install -domain trusted -removeRMS http://localhost:8080/j2me/midp/auction.jad 
Storage name: #Sun%0020#Microsystems%002c%0020#Inc%002e_#Ticket%0020#Auction_ 

Installing a MIDlet suite does not display the device skin or run the MIDlet after installing it. Installing a MIDlet suite downloads the JAR and JAD files and makes the MIDlet suite available to be run. (See Chapter 1, "Using the Graphical User Interface” for more information.)

Listing Installed MIDlet Suites

In order to remove or run a particular installed MIDlet suite, you need to know its number or storage name. Each MIDlet suite is assigned a number and a storage area when it is installed. The storage name of a MIDlet suite is the name of the suite’s storage area. To get this information about a MIDlet using the midp command, use the -list or -storageNames option.

For example, the following command lists the installed MIDlet suites by number:

c:\midp2.0fcs> bin\midp -list 
[1] 
  Name: SunSamples - Games 
  Vendor: Sun Microsystems, Inc. 
  Version: 2.0 
  Description: Sample suite of games for the MIDP. 
  Storage name: #Sun%0020#Microsystems%002c%0020#Inc%002e_#Sun#Samples%0020%002d 
%0020#Games_ 
  Size: 27K 
  Installed From: http://localhost:8080/midlets/games.jad 
  MIDlets: 
    TilePuzzle 
    WormGame 
[2] 
  Name: Ticket Auction 
  Vendor: Sun Microsystems, Inc. 
  Version: 2.0 
  Description: Ticket Auction demo. 
  Storage name: #Sun%0020#Microsystems%002c%0020#Inc%002e_#Ticket%0020#Auction_ 
  Size: 39K 
  Installed From: http://localhost:8080/midlets/auction.jad 
  MIDlets: 
    TicketLand 

The following example shows a command listing the installed MIDlet suites by storage name:

c:\midp2.0fcs> bin\midp -storageNames 
#Sun%0020#Microsystems%002c%0020#Inc%002e_#Sun#Samples%0020%002d%0020#Games_ 
#Sun%0020#Microsystems%002c%0020#Inc%002e_#Ticket%0020#Auction_ 

Listing MIDlet suites does not display the device skin.

Removing an Installed MIDlet Suite

When you uninstall a MIDlet suite, you delete any data that it had stored with the device emulator. When you next run the emulator, the removed MIDlet suite and its MIDlets will no longer appear on the application selector screen.

You uninstall a MIDlet suite by number or storage name. See "Listing Installed MIDlet Suites" for information on how to get these pieces of information. For example, if the example Demo MIDlet suite had a suite number of two, you would enter the following command to remove it:

c:\midp2.0fcs> bin\midp -remove 2 

As another example, if the example Games MIDlet suite had a storage name of #Sun%0020#Microsystems%002c%0020#Inc%002e_#Sun#Samples%0020%002d%0020#Games_, you would enter the following command to remove it:

c:\midp2.0fcs> bin\midp -remove #Sun%0020#Microsystems%002c%0020#Inc%002e_#Sun#Samples%0020%002d%0020#Games_ 

Removing a MIDlet suite does not display the device skin.

 


Contents Previous Next Index Using MIDP
MIDP Reference Implementation, Version 2.0 FCS