Mobile device emulator

Series 40 and Nokia Asha software platform devices include an emulator application that simulates the hardware and operating system of an actual mobile device. The emulator allows you to develop and test MIDlets on a computer before testing them on actual devices.

The emulator provides as faithful an emulation as possible of the operating system running on the target device, and includes processes and scheduling that are almost identical to those on the target device. However, there are necessarily some differences between the emulator and the target device, so testing MIDlets on actual devices remains an important part of the development process.

Figure: Nokia Asha software platform emulator (left) and Series 40 6th Edition Feature Pack 1 emulator (right)

You can integrate the emulator with both Nokia IDE for Java ME (Eclipse) and NetBeans, so that you can launch MIDlets directly into the emulator for debugging purposes. You do not need to restart the emulator for every debug session. You can leave the emulator running, rebuild the debugged MIDlet in the IDE, and then relaunch the MIDlet from the applications menu in the emulator.

You can also open MIDlets directly from the emulator by selecting File > Open and then selecting either the JAD or JAR file of the MIDlet. Any MIDlet you open is installed onto the emulator in a similar manner as on an actual device. You can also open image files, MMS files, web pages, and other supported media files. The emulator handles an opened file using the native application associated with the type of the file. For example, if you open an image file, the emulator launches the device's default image viewer for displaying the image.

Series 40 2nd Edition onwards MIDlet profiling is supported, which allows you to monitor the runtime state of a MIDlet as it is running in the emulator or on a device. You can retrieve and analyse information about the Java heap (memory usage), CPU usage in different threads, thread monitor locks, and so on. You can use this information to optimise the performance of the MIDlet. For more information about MIDlet profiling, see the SDK documentation.

For more information about a specific SDK and emulator release, see the SDK documentation.

Simulating events

You can use simulated events to test how your MIDlet behaves when a specific event, such as an incoming call occurs.

Nokia emulators allow you to simulate various mobile device events.

  1. Select Tools > Generate Event.

  2. Select the event you want to simulate. The emulator simulates the selected event.

    Figure: Simulating an incoming call in an Nokia Asha software platform 1.0 emulator

For more information about simulating events in an emulator, see the SDK documentation.

Diagnostics window

Nokia emulators provide a diagnostics window that allows you to monitor different types of runtime data from the emulator. If you are using a SDK, the diagnostics window also allows you to monitor runtime data from a device by way of the Device Connectivity Tool.

To open the diagnostics window from the emulator, select Tools > Diagnostics

Figure: Diagnostics windows in an Nokia Asha software platform 1.0 emulator

The diagnostics window displays data in panes. Both Series 40 and Nokia Asha software platform emulators provide the following types of data for monitoring a running MIDlet:
  • Diagnostic data on the MIDlet's HTTP connections (Traffic pane)

  • Tracing data returned by the MIDlet or the Java Runtime, for example, system output messages or MIDlet runtime error messages (Log / SystemOut pane)

  • Display data about the MIDlet's memory consumption (MIDP pane).

For more information see the SDK’s documentation.

Diagnostics and tracing

The diagnostics and tracing functionality allows you to monitor the activities of a MIDlet as it is running in an emulator. You can monitor the following types of data:
  • Diagnostic data on the MIDlet's HTTP connections (requests and responses)

  • Tracing data returned by the MIDlet, for example, system output messages

  • Tracing data returned by the Java Runtime, for example, MIDlet runtime error messages

Tip: To receive tracing data from a MIDlet running on a Series 40 device, use the Series 40 On-Device Debugger.

Nokia Asha SDK 1.0, provides a similar On-Device Debugger. For more information see the SDK’s documentation.

The Java Runtime provides the following standard output streams for MIDlets to return tracing data
  • System.out

    Use the System.out stream to trace the activities of the MIDlet while it is running. For example, you can set a System.out event to be triggered when the user selects a certain menu item. To write a line of output data, use the System.out.println method.

  • System.err

    Use the System.err stream to display error messages and other important information. To write a line of output data, use the System.err.println method.

System.out and System.err outputs are generated both in the emulator and on the device.