Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 3.0.5 for Windows
  Go To Table Of Contents
Go To Index


6 Running Projects in the Emulator

The Java ME SDK emulator simulates a CLDC or CDC device on your desktop computer. The emulator does not represent a specific device, but it provides correct implementations of its supported APIs. The SDK uses the device manager to detect devices and displays the available devices in the Device Selector window. See Section 13.1, "Run the Device Manager".

The Java ME SDK provides default device skins. A skin is a thin layer on top of the emulator implementation that defines the appearance, screen characteristics, and input controls.

If the Device Selector window is not visible, select Window > Device Selector.

6.1 Emulating Devices

The emulator runs applications on an emulated device or a real device. Before you can run an application from the SDK, the Device Manager, which manages both emulated and real devices, must be running. When the Java ME SDK runs, the Device Manager automatically launches and starts detecting devices. The default devices shipped with the SDK are automatically found and displayed in the Device Selector window.

6.1.1 The Device Manager on Windows

The Device Manager is a service and you can see it running in your Windows system tray. In the task manager, the process is labeled device-manager.exe.

device manager icon resides in Windows system tray

The Device Manager icon resides in the Windows system tray.

You can right-click on the icon and select Exit to stop the service.

Description of devmgrmenudef.gif follows
Description of the illustration devmgrmenudef.gif

6.2 Viewing Device Properties

The Device Selector window lists all available devices grouped by platform. If this window is not visible, select Window > Device Selector.

If no Java ME platform is registered in NetBeans, the Device Selector displays a node labeled No Device Found. If you see this message at startup, it typically means device discovery is incomplete and you just need to wait a few seconds.

Each sub node represents an emulator skin for a device. Two instances are provided for some CLDC devices, for example, DefaultCldcMsaPhone1 and DefaultCldcMsaPhone2 (DefaultCldcPhone has three default instances). Instances of the same device have the same capabilities but unique phone numbers, making it easy for you to test communication between devices of the same type. If you need an additional device instance, see Section 6.9, "Adding a Device Instance".

For Device names, see Section 8.4, "Java ME SDK User Directories". The properties for each device skin are stored in XML files in your user work directory. See Table 8-1.

See also: Section 6.2.1, "Platform Properties", Section 6.2.2, "Device Information", and Section 6.2.3, "Device Properties"

6.2.1 Platform Properties

To view platform properties from the device selector, click on the platform node (for example, CLDC or CDC). The Properties window is, by default, docked in the upper right portion of the user interface. If the Properties window is not visible, select Windows > Properties.

To view the platform properties in a separate window, right-click on the platform node and select Properties. The information in the docked properties window and the separate window is the same.

6.2.2 Device Information

In the Device Selector window, click on a device node. The Device Information tab opens in the central Main window. It displays a picture of the device and displays details, supported hardware capabilities, keyboard support, supported media formats, and the supported runtimes.

6.2.3 Device Properties

In the Device Selector window, click on a device node (such as VgaCdcPhone1) to display the device properties. The Properties window is, by default, docked in the upper right portion of the user interface. If the Properties window is not visible, select Windows > Properties.

6.3 Setting Device Properties

In the Device Selector Window, right-click on a device and select Properties. Any properties shown in gray font cannot be changed. You can adjust the device properties shown in black. Only CLDC options can be adjusted. The CDC options cannot be changed.

Phone Number. You can set the phone number to any appropriate sequence, considering country codes, area codes, and so forth. If you reset this value, the setting applies to future instances. The number is a base value for the selected device.

Heapsize. The heap is the memory allocated on a device to store your applications's objects. The Heapsize property is the maximum heap size for the emulator. You can choose a new maximum size from the dropdown menu.

JAM storage size in KB. The amount of space available for applications installed over the air.

Security Domain. Select a security setting from the dropdown menu. See Section 12.1, "Security Domains". Applies to CLDC platforms.

Locale. Type in the locale as defined in the MIDP 2.0 specification:

Remove MIDlet Suite in execution mode. If this option is enabled, record stores and other resources created by the MIDlet are removed when you exit the MIDlet (assuming the MIDlet was started in execution (non-OTA) mode).

Monitor. Checkboxes for Trace GC (garbage collection), Trace Class Loading, Trace Exceptions, Trace Method Calls, and Enable Tracing for System Classes activate tracing for the device the next time the emulator is launched. The trace output is displayed at runtime in the user interface Output window. Note that Trace Method Calls and Enable Tracing for System Classes return many messages, and emulator performance can be affected.

SATSA. See Section 20.1, "Card Slots in the Emulator".

Bluetooth. See Section 17.1, "Setting OBEX and Bluetooth Properties".

Payment. The properties are MCC (mobile country code), MNC (mobile network code), and Passed Transactions Limit. See Section 27.2, "Running JBricks".

6.4 Opening a Serial Port

In application code, you can use"comm:COM1") to open a port on the device. On Windows, you can open a serial port such as COM1 or COM2.

6.5 Running a Project from the Device Selector

The SDK determines which open projects are suitable for a device. Right-click on the device and select a project from the context menu. If projects are not suitable they are displayed in gray font.

Description of device-selector-proj.gif follows
Description of the illustration device-selector-proj.gif

You can also launch the emulator to run a project from the command line, as explained in Section 13.3, "Emulator Command Line Options".

6.6 Running Projects Simultaneously on a Single Device

CLDC-based devices are capable of running multiple virtual machines.You can test this behavior in the emulator. Be sure the output window is visible in the SDK (select Window > Output > Output). To test this feature, follow these steps:

  1. Open the sample projects Games and AudioDemo.

  2. In the device selector, choose an MSA-compliant device and run Games. When the emulator launches run AudioDemo on the same device.

    As each MIDlet loads, the AMS automatically installs it.

  3. In AudioDemo, launch the Audio Player, and play the JavaOne theme.

    Select AudioPlayer, then from the soft menu, select 1, Launch. Select JavaOne Theme and press the Play soft button.

  4. In the emulator, choose Application > AMS Home, or press F4.

    Select Games. From the soft menu, select 1, Open. The music continues to play while you are able to simultaneously launch and play games.

  5. Select Application > AMS Home, or press F4. Highlight AudioSamples, and from the soft menu, select 2, Bring to foreground. Press the Pause soft key. The music stops playing.

  6. Select Application > AMS Home, or press F4. Highlight AudioSamples and from the soft menu, select 1, Open. Select Bouncing Ball from the list and press the Launch soft button. Select MIDI background and press the Play soft button.

  7. Select Application > AMS Home, or press F4. Select Application > Switch Running MIDlet. Select Audio Player and press the Switch to soft button. You can press the Play soft button to resume the Audio Player.

6.7 Emulator Features

Figure 6-1, "Emulator Features" shows common emulator features available on emulators for the CLDC platform.

Device Name. Shown in the upper window frame. See Table 8-1, "Device Names".

Transmission Indicator. On the upper left of the emulator image, this blue light turns on when a transmission is occurring. Typically you see it when an application is installed over-the-air, or when a message is being sent or received. For example, when you receive a message from the WMA console.

Menus. See Section 6.8, "Emulator Menus".

Device ID. See Table 8-1, "Device Names".

Exit Button. Pushing the button on the upper right of the emulator image has the same effect as selecting Application > Exit.

Emulator Status Bar. Information about the current system state is shown in the status bar at the bottom of the emulator window.

Figure 6-1 Emulator Features

Description of Figure 6-1 follows
Description of "Figure 6-1 Emulator Features"

6.8 Emulator Menus

The emulator for the CLDC platform has Application, Device, Edit, View, and Help menus.

The emulator for the CDC platform has Application, Device, View, and Help menus. The View and Help menus are the same on CDC and CLDC platforms. For CDC, the Device menu is not populated, and Application menu contains only the Exit option.

6.8.1 Application

The Application menu is fully populated for the CLDC platform. The Application options are as follows:

Option Accelerator Description

Run MIDlet suite

Emulator interface for launching MIDlets. To run sample applications, choose the apps\*\dist\*.jar file.

AMS Home


Exit the current application and return to the Application Management Software home.



Stops the currently running MIDlet.

Change Locale

This option only works with localized MIDlets.

Enter a locale identifier. The format is similar to Java SE 6, as follows:

2-letter-lang-code separator 2-letter-country-code

For example, en-US, cs-CZ, zh-CN, ja-JP. The separator can be a dash or an underscore.



Resume a suspended application.



Pause a running application.

Switch Running MIDlet


When you have multiple MIDlets running, toggle between them. You see a list of running MIDlets and you can chose the one you want to view. See Section 6.6, "Running Projects Simultaneously on a Single Device".


Exit button on emulator upper right

Close the emulator process and stop the build process (or processes).

6.8.2 Device

This menu is available on CLDC platforms. For CDC emulators the menu exists, but it is empty. Messages

Choose Device > Messages to see what is written in the message area. This is the emulator's Inbox. The Inbox displays messages that are addressed to the device, not an application on the device. The

  • MMS messages without an AppID in the address

  • SMS messages without a port in the address

  • SMS text messages with a port in the address, provided there is not a Java ME application listening on the specified port.

To test sending messages to the inbox use the WMA Console in Netbeans, or from the command line, use wma-tool.exe. Note that wma-tool.exe requires an AppID for MMS, so it can't be used to send a message. For SMS a port number is required, but you can use 0 for the port to send a message to the inbox. Orientation

Use this feature to test your application's ability to display in portrait and landscape formats. The default is 0 degrees. Change the orientation to 90, 180, or 270 degrees. You can also rotate 90 degrees clockwise (F8) or counterclockwise (F9) from the current position. External Events Generator

The External Events Generator allows you to interact with an application by injecting events. The interaction may be through a user interface, or through a script file. The following menu options each have a tab on the External Events Generator. The use of the External Events Generator is addressed in the discussion for each JSR.

6.8.3 Edit

The Edit menu provides basic editing utilities for the CLDC platform.

Option Accelerator Description



Copy selected material to the paste buffer.



Move selected material to the paste buffer.



Insert the contents of the paste buffer.

6.8.4 View

The View menu is available for both CLDC and CDC platforms. The only View option available is Always On Top.

Option Description

Always On Top

Keeps the emulator in the foreground. This is especially useful when you are running multiple emulator instances and you want to see them all and send messages between devices.

6.8.5 Help

The Help menu displays an abbreviated helpset specifically for the emulator window.

6.9 Adding a Device Instance

As described in Section 6.2, "Viewing Device Properties", a particular device emulator can have more than one instance, and each instance is differentiated by a number appended to the emulator name, as seen in Table 8-1. Each device instance is stored in a numbered directory. See Section 8.4, "Java ME SDK User Directories".

To create your own instance, follow these steps:

  1. Close the Java ME SDK.

  2. In the device-adapter directory (see Section 8.3, "NetBeans User Directories"), copy a numbered directory and rename it with the next number in the sequence, for example, 11 (see Table 8-1).

  3. In the copied directory, open the properties.xml file and change the name property string to a unique name.

    You can also change the values in

  4. In the system tray, right-click on the Device Manager icon and select Exit from the context menu.

  5. Start the Java ME SDK.

In the Device Selector you see a new node named Other. All your custom devices are listed here. To assign this device to a project, right-click the project, select Properties, and choose Platform. Your instance appears in the Device drop list.

You can also edit the device adaptor to create a new instance. For example, to create a second instance of the ClamshellCldcPhone, follow these steps:

  1. Go to the device adapter directory (see Section 8.4, "Java ME SDK User Directories").

  2. Make a copy of 1.bean, and name it 2.bean.

  3. Edit 2.bean to change the device number to 2. For example, ClamshellCldcPhone2.

  4. Exit the SDK and exit the Device Manager.

  5. Start the SDK. ClamshellCldcPhone2 is listed in the Other category.