|
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.
The midp command is in the midpInstallDir\bin directory. To use the command:
For example, if MIDP Reference Implementation was installed in the directory c:\midp2.0fcs:
midp command with any commands or options.
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:
The next sections describe some common options.
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:
\build\share\lib\internal.config\build\share\lib\system.configSee Appendix C, "The midp Command” for a complete list of the properties in each file. This section covers two topics:
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:
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:
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:
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
It is common to have to update the following property values:
com.sun.midp.io.http.proxy – Set this property if you must go through a proxy server when you use HTTP to reach the internet. The MIDP implementation will delegate the device emulator’s HTTP requests to the proxy. The value of this property has the form hostName:portNumber. For example:com.sun.midp.midlet.platformRequestCommand – Set this property if you are running a MIDlet that calls the MIDlet class’s platformRequest method. Its value should be a command that takes a URL as an argument, such as a browser, or a script, and properly handles the URL. If the URL is for a JAD file, the command must install the named package; if the URL is of the form tel:number, as specified in RFC2806 (
http://rfc.net/rfc2806.html), the command must, if it is possible on the platform, make a voice call to number.The following code example shows this property being set to use the Mozilla browser on a machine that has installed the browser in its default location:
c:\midp2.0fcs> bin\midp -Dcom.sun.midp.midlet.platformRequestCommand="C:\Program Files\mozilla.org\Mozilla\mozilla.exe"
If you set this property incorrectly, one of two errors will be displayed in the terminal window where you called the midp command:
PlatformRequest is not configured. This happens when the property has no value.
Spawning a handler process failed. Check the platformRequest configration.This happens if the property value is incorrect or if there has been a very rare and unexpected system error.
com.sun.midp.io.http.force_non_persistent – Set this property to true if you see problems with persistent connections when accessing your web server. These problems could include incorrectly indicating the server sent bad data, displaying only parts of documents and images, and other problems. (You could also try turning off persistent-request capabilities in your web server.) The following code example shows this property being set to true:system.i18n.encoding and system.i18n.lang – Set these properties if your device will use something other than a Western European encoding (latin1) for the English language. The following code example shows these properties being set to support a Japanese encoding and language: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.)
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.
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:
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.
|
Using MIDP MIDP Reference Implementation, Version 2.0 FCS |
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.