Вы находитесь на странице: 1из 98

2010

Nokia MIDP Application Guide

ADNAN FAKHAR
4/16/2010
Document Revision History
Name Date Description Version

Adnan Fakhar April Setting up MIDP Application for Nokia 1.0


16,2010 Devices.

Table of Contents
Supported Development Environments and APIs......................................................................................................................5

The Series Developer Platform 2.0 SDK for Symbian OS – For MIDP supports usage of Unified Emulator Interface (UEI).........5

The Series 80 Developer Platform..............................................................................................................................................5

Supported development environments.................................................................................................................................5

Supported APIs....................................................................................................................................................................... 5

Emulator GUI and its functions...............................................................................................................................................6

Using the Keyboard................................................................................................................................................................ 8

Differences between Emulator and the Nokia 9500 Communicator device.........................................................................10

Introduction to Java™ technology for Series 80.......................................................................................................................11

Mobile Information Device Profile (MIDP) 2.0.....................................................................................................................11

Connected Limited Device Configuration (CLDC) 1.1............................................................................................................11

MIDlet.................................................................................................................................................................................. 11

MIDlet lifecycle..................................................................................................................................................................... 12

startApp() Method......................................................................................................................................................12
pauseApp() Method....................................................................................................................................................12
destroyApp() Method.................................................................................................................................................13
MIDP User Interface APIs.....................................................................................................................................................13

MIDlet Suites and Application Descriptors...........................................................................................................................13

HelloWorld MIDlet............................................................................................................................................................... 15

Getting Started with MIDP Application Development..............................................................................................................19

What you should already know............................................................................................................................................19


What you will need...............................................................................................................................................................20

Checking the Application Development Environment..........................................................................................................20

Troubleshooting: PATH variable not set or not set correctly.....................................................................................21


Setting the PATH variable...........................................................................................................................................22
Creating an Application............................................................................................................................................................24

Basics of creating a MIDlet for Series 80..............................................................................................................................24

Building the Hello World MIDlet...........................................................................................................................................25

Compiling the HelloWorld MIDlet..............................................................................................................................26


Preverifying the compiled HelloWorld MIDlet...........................................................................................................26
Packaging the Hello World MIDlet........................................................................................................................................27

Creating the manifest file...........................................................................................................................................27


Creating the application JAR File................................................................................................................................28
Running the HelloWorld MIDlet in the emulator.................................................................................................................30

Installing your application on device....................................................................................................................................31

Deployment with Wireless Link..................................................................................................................................31


Deployment with PC Suite Application Installer........................................................................................................31
Using the SDK with Nokia Developer's Suite 2.2 for J2ME™.....................................................................................................32

Installation and configuration..............................................................................................................................................32

Development........................................................................................................................................................................ 35

Using the SDK with Borland® JBuilder®9....................................................................................................................................37

Installation and configuration..............................................................................................................................................37

Development........................................................................................................................................................................ 43

Debugging with Borland JBuilder 9.......................................................................................................................................45

Using the SDK with Borland® JBuilder®X....................................................................................................................................47

Installation and configuration..............................................................................................................................................47

Development........................................................................................................................................................................ 53

Debugging with Borland JBuilderX.......................................................................................................................................55

Using the SDK with Sun J2ME™ Wireless Toolkit 2.1................................................................................................................57


Installation and configuration..............................................................................................................................................57

Development........................................................................................................................................................................ 58

Debugging with the Sun J2ME Wireless Toolkit....................................................................................................................58

Using the SDK with Sun Java Studio Mobility 6 2004Q3...........................................................................................................60

Installation and configuration..............................................................................................................................................60

Development........................................................................................................................................................................ 61

Debugging with the Sun Java Studio Mobility 6....................................................................................................................63

Using the SDK with IBM® WebSphere® Studio Device Developer..............................................................................................66

Installation and configuration..............................................................................................................................................66

Starting the IBM® WebSphere® Studio Device Developer for the first time...............................................................66
Configuring as a UEI Emulator Device........................................................................................................................67
Development........................................................................................................................................................................ 69

Creating a new MIDlet Suite.......................................................................................................................................69


Importing examples to the MIDlet suite....................................................................................................................73
Launching a MIDlet in the Series 80 Emulator...........................................................................................................76
Installation and configuration..............................................................................................................................................80

Setting Java Debug Preferences.................................................................................................................................82


Development........................................................................................................................................................................ 83

Create a new project..................................................................................................................................................83


Import example code to project.................................................................................................................................88
Building application....................................................................................................................................................90
Running application in emulator................................................................................................................................90
Debugging a MIDlet....................................................................................................................................................90
Using the SDK from the command-line....................................................................................................................................91

Standard command-line syntax............................................................................................................................................91

UEI command-line syntax.....................................................................................................................................................93

Debugging from the command-line......................................................................................................................................95

Media content emulation.........................................................................................................................................................96


Camera................................................................................................................................................................................. 96

Audio Recording................................................................................................................................................................... 97

Getting started..................................................................................................................................................................... 98

Communicating with other Nokia products..........................................................................................................................98

How to configure NCF integration......................................................................................................................................100

Documents included with Series 80 Developer Platform SDK............................................................................................101

Forum Nokia....................................................................................................................................................................... 102

Java..................................................................................................................................................................................... 102

Terms and Abbreviations........................................................................................................................................................102

Before Writing MIDlet Application....................................................................................................................................105

http://www.forum.nokia.com/Technology_Topics/Development_Platforms/Java.xhtml.............................................105

I need an SDK. Which is the right one for my phone?.......................................................................................................105

I can build an application on a PC, but how do I get it onto a phone?.............................................................................106

Series 80 MIDP SDK sup


ports the following APIs:

 MIDP 2.0 (JSR-118),

 CLDC 1.1 (JSR-139),

 Wireless Messaging API 1.1 (JSR-120),

 Mobile Media API 1.1 (JSR-135),

 Bluetooth API (JSR-82),

 FileConnection API and Personal Information Management (PIM) API (part of Optional
Packages JSR-75), and Nokia UI API.

The Series 80 MIDP SDK works as a plug-in with Nokia Developer’s Suite for J2ME™ and can also
be used with Java IDEs. The Series 80 MIDP SDK supports Unified Emulator Interface (UEI)
interface. IDE support includes Borland® JBuilder® 9 Mobile Edition, Borland® JBuilder® X Mobile
Edition, Sun Java™ Studio Mobility 6 2004Q3, Sun J2ME™ Wireless Toolkit 2.1, Eclipse 3.0 and
IBM® WebSphere® Studio Device Developer versions 5.6 and 5.7.

Together with the IDE, the Series 80 MIDP SDK provides functionality required for MIDP
application development, including API libraries, emulator, example MIDlets and user
documentation. The Series 80 MIDP SDK Emulator allows developers to run and test the behavior
of the MIDlet on your PC or Laptop. Emulator provides the graphical interface of a Nokia 9500
Communicator and device functionality to test MIDP applications.

1.1

Supported Development Environments and APIs


The Series Developer Platform 2.0 SDK for Symbian OS – For MIDP supports usage of Unified
Emulator Interface (UEI).

The Series 80 Developer Platform

1.2 Supported development environments


1 • Borland® JBuilder® 9 Mobile Edition
2 • Borland® JBuilder® X Mobile Edition
3 • Sun Java™ Studio Mobility 6 2004Q3
4 • Sun J2ME™ Wireless Toolkit 2.1
5 • Nokia Developer's Suite for J2ME™, Version 2.1 or Version 2.2. for Windows. Version 2.2
includes support for Eclipse 3.0
6 • IBM® WebSphere® Studio Device Developer, Version 5.6 or Version 5.7. (Debugging on
Series 80 MIDP SDK emulator is not supported with IBM ® WebSphere® Studio Device Developer)

7 It is recommended to install the IDE for the Java development before the Series 80 MIDP
SDK installation.

1.3 Supported APIs


Series 80 Developer Platform 2.0 SDK for Symbian OS – For MIDP includes Java class libraries, along with
documentation, and support for the following APIs:
• MIDP 2.0 (JSR-118) Extends and enhances the J2ME™ Mobile
Information Device Profile (JSR-37)
• CLDC 1.1 (JSR-139) Revised version of the J2ME™ Connected,
Limited Device Configuration (CLDC)
• Java APIs for Bluetooth (JSR-82) - Set of APIs to allow Java-enabled devices
OBEX is not supported to integrate into a Bluetooth
environment.
• Wireless Messaging API 1.1 (JSR-120) Set of APIs which provides standard
access to wireless communication
resources, designed to run on J2ME
configurations.
• Mobile Media API 1.1 (JSR-135) Set of APIs for J2ME allowing access and
control of basic audio and multimedia
resources.
• PDA Optional Packages for J2ME™ Optional Packages for features commonly
Platform, FileConnection API and found on J2ME mobile devices: one for
Personal Information Management accessing PIM data and one for accessing
(PIM) API (JSR-75) file systems.
• Nokia UI API It is recommended to use the MIDP 2.0
API, which includes the same
functionality as the Nokia UI API.

Series 80 Developer Platform SDK Emulator

The Series 80 Developer Platform SDK emulator allows you to run and test the behavior of MIDP
applications on your PC before installing them on a real device. It provides the graphical interface
of a Nokia 9500 Communicator and device functionality to test your application.

1.4 Emulator GUI and its functions

To start the emulator as standalone, do as follows:


 From the start menu, select Start > Programs > Nokia Developer Tools > DP 2.0 SDKs >
Series 80> MIDP > Emulator (Debug).
 To launch the emulator from the command line, use the debug version located in SDK
directory:
C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\bin\epoc32\release\wins\udeb\epoc.exe

1 Note that the emulator is only able to run applications packaged into a MIDlet Suite as
specified in the MIDP specification. This means that both a JAD file (Java Application Descriptor)
and a JAR file (Java Archive) must be created before running the application.

The Series 80 Developer Platform SDK emulator’s main window simulates the Nokia 9500
Communicator’s PDA interface without the keyboard. The emulator replicates the user interface
of the Nokia 9500 Communicator’s interface with respect to its soft-key definitions, menu
selections, and message display. You can use the PC keyboard and mouse to control the
emulator.

The appearance of the emulator is faithful to the appearance of the device, although the contrast
and color-rendering capabilities of each might differ slightly due to differences in monitor
calibration and imaging technologies.

Figure 1: The Series 80 Developer Platform SDK emulator window

The Desk contains application icons. In the emulator, applications are opened from the desk with the Open command button. When
an application is opened, the desk becomes the Application area . That is, the application is displayed instead of the desk.

To simulate pressing the buttons on a Nokia 9500 Communicator device, click the corresponding
command keys on the emulator window with the mouse. To access the PDA menu press F1. The
menu structure displayed in the emulator’s user interface is identical to that of the Nokia 9500
Communicator device, although not all menus in the Series 80 Developer Platform SDK work
identically to their device counterpart. For example, you cannot use a telephony application to
make a phone call on the SDK.
1.5

1.6 Using the Keyboard


You can use the PC keyboard to control the emulator. Navigating the emulator user interface is
done with the arrow keys (up, down, left, right).

The following table lists the emulator function keys and keyboard shortcuts:

Key Function

Esc Cancels currently displayed dialogs or menus.


Enter Select / OK
F1 Displays the PDA menu.
up, down, left, right Correspond the navigation keys.
F9 Restore the emulator from emergency shutdown.
F10 Simulates an emergency shutdown. Press F9 to restore.
ALT + left Activate/deactivate Bluetooth
ALT + right Activate/deactivate Infrared
Shift + Ctrl + Alt + K Kills the application with the current keyboard focus.

Table 1: Series 80 emulator keyboard shortcuts

1 Note: Symbian function keys 'Alt + F2' and 'F8' do not work in emulator. Window server shortcut keys 'Ctrl + Alt + Shift +
E/D/W/H' don't work in emulator. The tasklist key ‘Ctrl + Alt + Shift + T’ does not work in the emulator.

CBA buttons
The Command Button Area (CBA) on the right of the Application area correspond to buttons to
access key commands or functions within an application. The functionality of the Command
buttons is application-specific.

The command text is underlined if the Enter key has been assigned to that command. When a
command is dimmed, it cannot be used.
Figure 2: Command buttons in emulator

The following table shows the guidelines for usage of CBA buttons. Button number one is the
topmost command button.

Button Command type Examples

1. The most frequently used command. Open / OK / Select /


Accepting and starting functions. Call / Connect / Send /
Can be control sensitive in dialogs. Start / Change / Set /
Yes
2. The second most frequently used command. Edit / Add / Change
Helps navigation inside view. Window / Options
Enables switching between different views.
Opens options dialog.
3. Same type of commands as Button 2. New / Delete /
A command that deletes or performs other Remove /
“destructive” command. Deselect / Options
4. Closes application and dialogs. Close / Cancel / Hang
Saves entries. up /
Cancels confirmation notes. Disconnect / No /
Generally, provides the means to go back safely. Done /
Exit (application main
level)

2 Differences between Emulator and the Nokia 9500 Communicator device

While the Series 80 2.0 Developer Platform SDK Emulator simulates most of the behavior of the
Nokia 9500 Communicator device, there are some important differences between the emulator
and the real device.
1 • Telephony functionality is not fully supported in emulator. Therefore some applications are
not fully functional in emulator.
2 • The emulator does not contain the phone interface of the device; it simulates Nokia 9500
Communicator’s camera functionality with a separate Camera application.
3 • Nokia 9500 Communicator may support additional multimedia formats that are not
supported in the Series 80 Developer Platform SDK.
4 • Some hardware related features (such as SIM card related functionality) do not work in the
emulator.
5 • The emulator can imitate functionality, but it cannot fully reflect the timing responses of
the real device. Any kind of application that depends on timing or performance of the device
is not accurate on the emulator.
6 • The emulator simulates networking functionality using either an Ethernet adapter or a
wireless WLAN adapter. The network speed and performance are dependent on PC’s
hardware and the configuration of network adapters and thus deviate from real device.
7 • The emulator does not load all services upon initialization, whereas the real device does. To
load the services, such as Bluetooth, the application to be used must perform this task.
8 • The Bluetooth protocol stack and lower-level implementation are different in the emulator
and a real device. You cannot use WLAN and Bluetooth in the emulator at the same time.
9 • Emulator does not emulate the real memory size of a Nokia 9500 Communicator device.
10 • The emulator is a single process in the Windows environment. Even though all applications
mimic process behavior, they are actually implemented as threads in the emulator process.
This can affect applications that depend on process behavior, such as scheduling activity, and
resources such as memory that processes consume.
11 • All ports that the emulator simulates as being directly connected to the emulator device
are actually PC ports. The timing and performance of these ports are dependent on PCs
hardware and the configuration of Windows. As a result, any kind of real-time input/output
management is very difficult.

2.1 Introduction to Java™ technology for Series 80


This section provides basic information on Java™ technology. It is recommended that you
familiarize yourself with these basics before moving on to creating your own Java application
with the Series 80 MIDP SDK. Here we will go through the basics of the application environment,
what an application consists of and how it works.
3 Mobile Information Device Profile (MIDP) 2.0

The Mobile Information Device Profile (MIDP) is a set of Java APIs that together with the
Connected Limited Device Configuration (CLDC) provide a complete J2ME application runtime
environment for mobile information devices (MIDs). The MIDP specifications (JSR-118) define
minimum hardware, software, networking, application requirements, as well as standard system
APIs for devices that support MIDP.

MIDP is intended for “connected” devices such as communicators and smartphones, which are
characterized by having limited Central Processing Unit (CPU), memory, keyboard, and display
capabilities.
For more details on MIDP and the related specifications, see http://java.sun.com/products/midp/ .

Connected Limited Device Configuration (CLDC) 1.1

Connected Limited Device Configuration (CLDC) defines the Java language features and the core
libraries of the Java Virtual Machine (JVM).
For more details on CLDC and the related specifications, see http://java.sun.com/products/cldc/ .

MIDlet

Java applications developed with the SDK are called MIDlets. A MIDlet is an application, which
has been written for the Java 2 Micro Edition (J2ME) Mobile Information Device Profile (MIDP).

A simple example of a MIDlet is the HelloWorld example application provided with the SDK.
MIDlet lifecycle

MIDlets are designed to co-exist with other applications on a Mobile Information Device (MID).
The MIDlet lifecycle is pivotal in enabling this co-existence. Basically, a MIDlet can be in one of
the following states: paused, active, or destroyed.

The Application Management Software (AMS) controls the state of a MIDlet by directing a MIDlet
to start, pause, or destroy itself. It constructs a MIDlet and communicates changes in its state by
calling the following methods, which every MIDlet must implement: startApp(), pauseApp(), and
destroyApp().

All MIDlets start out in the paused state. When a user starts an application, the AMS calls the
startApp() Method of the MIDlet in question, after which the MIDlet is in active state (that is, the
application is opened).
3.1 startApp() Method

When users open a Java application on their device, the AMS calls the startApp() method. In this
case, the MIDlet is newly constructed with this method. In the case of such a newly constructed
MIDlet, the startApp() method should call Display.getDisplay(this).setCurrent(startup_screen) to
invoke the startup screen of the MIDlet (that is, application) in question.

The startApp() method is also invoked by the AMS when a MIDlet is returned from the paused
state. In this case, the startApp() method will typically need to restore the state it was in before it
was paused.

3.2 pauseApp() Method

When users pause (but do not close) an application, the AMS calls the pauseApp() method. In
this case, the application is paused and it is no longer displayed in the User Interface (UI) to the
user. However, any threads or timers created by the MIDlet in question will continue to run
unless stopped manually. These threads keep on running by default, because the application will
need to restore its state when it is reactivated with the startApp() method.

3.3

3.4 destroyApp() Method

When users close an application, the AMS calls the destroyApp() method. This method instructs
the MIDlet to release all the resources it has reserved and to close down as soon as possible. In
effect, this means that the application in question closes all input and output streams, terminates
all threads, and cancels all timers. Once the destroyApp() method has been called, the MIDlet
ceases to access the display, in other words, the application is no longer displayed in the UI to
the user.

4 MIDP User Interface APIs


The MIDP User Interface (UI) has a high-level and low-level API.

The high-level API classes Alert, Form, List, and TextBox are extensions of the abstract class
Screen. These are designed to provide abstractions and components that are highly portable
across different Mobile Information Devices (MIDs), as the application takes care of aspects such
as drawing, font characteristics, navigation, and scrolling. A particular device’s implementation of
these classes performs the adaptation to its hardware and native UI look and feel.
The low-level API is based on use of the abstract class Canvas. In comparison with the high-level
APIs, this class allows applications to have more direct control of the UI by permitting greater
control of what is drawn on the display and reception of low-level keyboard events.

MIDlet Suites and Application Descriptors

A Java archive (JAR) file contains the class files, resource files, and the manifest file for the J2ME™
application. JAR files can be either created manually with the Sun JAR.EXE utility, or can be
created using IDEs. One JAR file can contain one or more MIDlets. A JAR file that contains
multiple MIDlets is called a MIDlet suite. The Jar file is the application file which is downloaded to
Series 80 device.

All MIDlets are deployed to devices as suites. MIDlets in the same suite share the same
execution environment (virtual machine) and can interact with one another. Each MIDlet suite
JAR file has an associated Application Descriptor (JAD file) used to describe its contents. The
application descriptor MIME type is text/vnd.sun.j2me.app-descriptor. The file extension of such
an application descriptor must be .jad. The application management software (AMS) uses the
descriptor to manage each MIDlet included in the suite, that is, to verify that a MIDlet is suited
for execution on the device before loading the MIDlet suite JAR file. The JAD file contains the
attributes for the AMS, as well as the application-specific attributes the MIDlet suite itself will
use.

The MIDP 2.0 specification defines the rules for the using the attributes. You can specify
attributes in both the descriptor and the manifest. Attribute names that begin with “MIDlet-“ or “MicroEdition-“ are
reserved and used by the AMS.

The following table shows you where each attribute may or must appear:

Attribute Manifest Descriptor

MIDlet-Name Mandatory Mandatory


MIDlet-Version Mandatory Mandatory
MIDlet-Vendor Mandatory Mandatory
MIDlet-Jar-URL - Mandatory
MIDlet-Jar-Size - Mandatory
MIDlet-Install-Notify Optional Optional
MIDlet-Delete-Notify Optional Optional
MIDlet-Delete-Confirm Optional Optional
MIDlet-Info-URL Optional Optional
MIDlet-Description Optional Optional
MIDlet-Icon Optional Optional
MicroEdition-Profile (1 (2 Mandatory Mandatory
MicroEdition-Configuration (1 (3 Mandatory Mandatory
MIDlet-<m> (1 (4 Mandatory Mandatory
MIDlet-Push-<n> (5 Optional Optional
MIDlet-Data-Size Optional Optional
MIDlet-Permissions Optional Optional
MIDlet-Permissions-Opt Optional Optional

(1
Must occur in manifest or descriptor, it may appear in either, but it is not optional
(2
Same as the System property microedition.profiles
(3
Same as the System property microedition.configuration
(4
<m> is an integer, starting at 1 and incremented by 1 for each MIDlet
(5
<n> is an integer, starting at 1 and inceremented by 1 for each Push Registry entry

5 HelloWorld MIDlet

This section describes the general structure and design of the simple HelloWorld application.

The HelloWorld application is a simple MIDlet included with the SDK as an example application.
When opened, the application displays a ‘Hello World’ message on the display of the device.
Selecting the Exit command closes the application.
Figure 3: Hello World application

The structure of the HelloWorld application is depicted below:


Figure 4: Structure of the HelloWorldMIDlet

The HelloWorldMIDlet class extends the javax.microedition.midlet.MIDlet class. It uses the MIDP
high-level API javax.microedition.lcdui.TextBox class to enter and edit text, in this case, ‘Hello
World’.

The TextBox class extends the abstract class Screen, which, in turn, extends the abstract class
Displayable. The TextBox UI component has a string contents area that allows users to enter and
edit text.

The HelloWorldMIDlet class also implements the CommandListener interface used to receive
user input from the command area.

The functionality of the HelloWorldMIDlet is the following: The startApp() method sets the
MIDlet’s current Display to the HelloWorldMIDlet object, if a current display does not already
exist. If the HelloWorldMIDlet object receives an Exit command from the user interface, it calls
the commandAction() method of the HelloWorldMIDlet. The HelloWorldMIDlet then handles the
MIDlet state transition to a Destroyed state. See below for the HelloWorldMIDlet.java example
code.

/* Copyright (c) 2003, Nokia Corporation. All Rights Reserved */

package com.nokia.examples.lcdui.helloworld;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
* This class illustrates the implementation of a simple MIDlet that initially
* displays a "HelloWorld!" message to the screen and allows the user to edit
* that message.
* <p>
* This class extends the class javax.microedition.midlet.MIDlet. It
* creates and maintains references to a TextScreen object and a
* TextEditor object.
* <p>
* Note that the HelloWorldMIDlet class has no constructor. MIDlet
* contructors are not required to do anything because intializing of the
* object is better performed in the startApp() method.
*
* @author Nokia Corporation
* @version 1.0
*/
public class HelloWorldMIDlet extends MIDlet {

/** Displays the message on the screen. */


private TextScreen textScreen;
/** Allows the user to edit the message displayed. */
private TextEditor textEditor;
/** A generic way of indicating whether startApp() has previously been called. */
private Display display;

/**
* Creates an instance of TextScreen if one has not already been
* created and tells the framework to set this instance of TextScreen
* as the current screen.
*/
public void startApp() {
if (display == null) {
// First time we've been called.
display=Display.getDisplay(this);
textScreen = new TextScreen(this, "Hello World!");
}
display.setCurrent(textScreen);
}
/**
* This must be defined but no implementation is required because the MIDlet
* only responds to user interaction.
*/
public void pauseApp() {
}

/**
* No further implementation is required because the MIDlet holds no
* resources that require releasing.
*
* @param unconditional is ignored.
*/
public void destroyApp(boolean unconditional) {
}

/**
* A convenience method for exiting.
*/
public void exitRequested(){
destroyApp(false);
/*
* notifyDestroyed() tells the scheduler that this MIDlet is now in a
* destroyed state and is ready for disposal.
*/
notifyDestroyed();
}

/**
* Implements the transition from the TextEditor screen to the TextScreen screen.
*
* @param string is the new text to be displayed. It is null if the text is
* not to be changed.
*/
public void textEditorDone(String string) {
if (string != null) {
textScreen.setCurrentText(string);
}
display.setCurrent(textScreen);
}

/**
* Implements the transition from the TextScreen screen to the TextEditor screen.
*/
public void textEditorRequested() {
String currentText = textScreen.getCurrentText();
if (textEditor == null) {
textEditor = new TextEditor(this, currentText);
} else {
textEditor.setText(currentText);
}
display.setCurrent(textEditor);
}
}

Example 1: HelloWorldMIDlet.java

5.1 Getting Started with MIDP Application Development


The aim of this section is to guide you through your first steps in developing a Java application for
the Series 80 Platform with the Series 80 MIDP SDK. With the help of the guide, you will learn the
basics of the environment and the tools, after which you will be able to create your first simple
Java application for the Series 80 Platform. Once you have grasped the essentials of application
implementation, you can then move on to design and create more versatile applications on your
own.

6 What you should already know


Although this guide aims to provide a general introduction to Java technology, it is recommended
that you look into some more comprehensive introductions to Java. As the Java technology was
created by Sun technologies Inc., a good place to find such sources is the java.sun.com
(http://java.sun.com /) website, and its wireless pages
(http://developers.sun.com/techtopics/mobility/ ) in particular.

In addition to the above, familiarity with the basics of wireless communication is also
recommended.

What you will need

You should have the following tools and resources available on your PC before you can start to
develop Java MIDP applications using the Series 80 MIDP SDK:
1 • Microsoft Windows XP with Service Pack 2 or Microsoft Windows 2000 with Service Pack
3
2 • Java 2 Standard Edition (J2SE) SDK version 1.4.1_02 or higher The J2SE SDK provides the
Java compiler and other tools used in application development. You can download the J2SE SDK
at http://java.sun.com/j2se
3 • The Series 80 Developer Platform 2.0 SDK for Symbian OS – For MIDP installed on your
PC
4 • A text editor, such as WordPad

2 You can develop applications and view them in the emulator with a minimal development
environment, that is, by using a simple text editor and command prompts. Application
development in this minimal development environment does not call for configuring the
emulator. Instead of the minimal development environment described in the Getting Started
section, you might wish to use a more robust and user-friendly development environment, such
as Borland JBuilder or Sun J2ME™ Wireless Toolkit.

7 Checking the Application Development Environment

When you start developing an application for the first time with the Series 80 Developer Platform
2.0 SDK for Symbian OS – For MIDP, you should first check that the development environment is
set up properly. This involves, for example, checking that the paths for the Java compiler and
preverifier tool are set correctly. This section provides instructions on how to test and
troubleshoot the needed path settings.

You can run the SDK without setting the PATH variable. However, setting the PATH variable
allows you to run the executables (javac.exe, preverify.exe) from any directory without having to
specify the full path to the executable every time you run it. See section 5.3.2, “Troubleshooting:
PATH variable not set or not set correctly” for detailed instructions on how to set the path.

Checking the paths for the Java compiler and preverifier tools
1 1. To check the Java compiler (javac.exe) settings, enter the following command in the
Command Prompt:
2 javac
You should get the following output on the screen:

Usage: javac <options> <source files> where possible options include:…

If you get an error message, see section 5.3.2, “Troubleshooting: PATH variable not set or not set
correctly”.
3 2. To check the preverifier tool (preverify.exe), enter the following command in the
Command Prompt:
4 Preverify

You should get the following output on the screen:

Usage: preverify [options] classnames|dirname… where options include:…

If you get an error message, see section 5.3.2, “Troubleshooting: PATH variable not set or not set
correctly”.

7.1 Troubleshooting: PATH variable not set or not set correctly

When testing the application environment settings, you may get the following error message:
“The name specified is not recognized as an internal or external command, operable program or
batch file” (Windows 2000, XP) .

This means that Windows cannot locate the Java compiler (javac.exe) or the preverifier tool
(preverify.exe). See examples below on how to specify their locations for Windows.

Example 1: To specify the location of the Java compiler: If you installed the Java 2 Software
Development Kit in, for example, C:\jdk1.4, enter the following command in the Command
Prompt:

C:\jdk1.4\bin\javac
Example 2: To specify the location of the preverifier tool:

For example, for the default C:\Nokia\Devices\S80_DP2_0_MIDP_SDK, enter the following


command in the Command Prompt:

C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\bin\preverify

Note that in this case each time you compile or preverify an application, you have to precede
your javac and preverify commands with C:\jdk1.4\bin\ or
C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\bin\, such as, j2sdk1.4.2_<version>\bin\javac
MyClass.java. To avoid this, update the PATH variable as instructed in the following section.

7.2 Setting the PATH variable

To avoid having to enter the full path every time you need to compile or preverify a MIDlet, it is
useful to set the path permanently so it will persist even after rebooting. This is done by adding
the full path of the directory to the PATH variable. Typically, this full path is
C:\j2sdk1.4.2_<version>\bin for the Java compiler and
C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\bin for the preverifier.

Complete the following steps to set the path permanently on Microsoft 2000 and XP:
5 1. Choose Start > Settings > Control Panel > System
6 2. Go to the Advanced tab and select Environment Variables
7 3. Locate the Path variable in the User Variables or System Variables If you are not sure
where to add the path, enter it as the last Path variable value listed in User Variables.
8 4. Select the Path variable and click Edit
9 5. Enter the path into the variable value field, for example, as follows:
C:\j2sdk1.4.2_<version>\bin for the compiler C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\bin for
the preverifier

10 Warning: Do not delete the existing path settings. Deleting the settings may affect the
functioning of the system or other programs.

Note: The PATH can be a series of directories separated by semi-colons (;). Microsoft Windows
looks for programs in the PATH directories in the order from left to right. You should have only
one bin directory specified for the Java SDK at a time (those following the first one are ignored).
If there is a path setting already specified, you can update it with the path given here.

6. Click Set, OK or Apply.

The new path is now set for each time you open the Command Prompt.
You can verify the settings by completing the steps detailed in section
5.3.1, “Checking the paths for the Java compiler and preverifier tools”.

7.3 Creating an Application


In this section we will go through the steps that are needed in creating a MIDP application, a
MIDlet, for the Series 80 Platform with the SDK. The idea is, that by the end of this section you
will have a MIDlet running on a Series 80 Platform device.
7.4 Basics of creating a MIDlet for Series 80

The SDK comes with several example MIDP applications that demonstrate various possible
applications that you can develop for the Series 80 Platform. Thus, a good way to familiarize
yourself with how to use the SDK is to build and run an example application. This will not only
guide you through the basic steps of building an application, but will also introduce you to the
emulator and its functionality.

In this section we will go through the main tasks involved in creating a MIDP application (that is,
a MIDlet) with the SDK. These steps will then be covered in more detail in the following sections.

1 Note: The task sequence in this section presumes that you have already installed the SDK
and that the prerequisites for installation and use outlined in section 5.2, “What you will need”
and 5.3, “Checking the Application Development Environment” above have been met. It is also
recommended that you have a Series 80 Platform target device to which you can upload the
application created in this section. For more detailed information on installation and related
requirements, please refer to the Series 80 Developer Platform 2.0 SDK for Symbian OS – For
MIDP Installation Guide [1].

Building the Hello World MIDlet

In section 6.2, “Building the Hello World MIDlet” you will compile a simple interactive Hello
World MIDlet. Although this application is very basic in that it displays only a simple string on the
phone screen, it can be easily adapted to make more complex applications.

Packaging the Hello World MIDlet

Before running the MIDlet in the emulator or installing the MIDlet to your phone you will first
need to package it for installation. This involves creating a manifest file, application JAR File and
application JAD file.

Step 3: Running the Hello World MIDlet in the emulator

After packaging the MIDlet you can can run it in the emulator. With the emulator you can see
how the application would run on a real phone

After building an application and running it in the emulator, typically the next phase in
application development is testing and debugging before uploading it to your phone. This is
sometimes referred to as the ‘edit/compile/build cycle’.

Step 4: Installing your application on device


Although a simple procedure as such, installing a MIDlet to a Series 80 phone varies depending
on the specific device model. The section 6.5, “Installing your application on device” will,
nevertheless, provide general instructions on how to install a MIDlet to your phone as well as an
example on how to do this.

7.5 Building the Hello World MIDlet


This section describes how to compile and preverify a simple example MIDlet.

2 Note: The application development described in this guide is done using a simple editor
and command prompt. More advanced development environments that you can use include, for
example, Borland JBuilder. Notice that before starting to use these in connection with SDK, you
will need to configure them so that you can run the Series 80 emulator (included with the SDK)
with them. For instructions on how to use the above mentioned development environment,
please refer to the Help documentation provided with the tool in question. For instructions on
how to build and run example applications, see the Example Applications section in the SDK Help.

7.6

7.7 Compiling the HelloWorld MIDlet


To compile the HelloWorld example MIDlet, do the following:
3 1. In the Windows Command Prompt, use the mkdir command to create a directory into
which the Java compiler should output the classes created in compiling the MIDlet. Enter the
following command:

4 mkdir C:\tmpclasses

5 2. Use the cd command to switch to the Series80ex\src\ subdirectory of the directory


where you installed the SDK. Enter, for example, the following command in the Command
Prompt:

6 cd C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\Series80ex\src

7 3. Compile the Hello World MIDlet by entering the following command in the Command
Prompt:
8 javac -d C:\tmpclasses –classpath
C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\lib\*.zip;C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\Seri
es80ex\src com\nokia\examples\lcdui\helloworld\HelloWorldMIDlet.java

The HelloWorld MIDlet has now been compiled to the tmpclasses directory. Next, you will need
to preverify the classes that have been created.

Preverifying the compiled HelloWorld MIDlet

To allow more efficient memory usage on the target device, checking the code for correctness is
done offline by using the preverifier tool. The preverifier checks that the classes are correct and
inserts additional information into the class files. The Virtual Machine looks for this information
and uses it for a much simpler verification based on the data collected by the preverifier. The
preveifier ensures that the MIDlet does not violate the MID’s security policies.

To preverify the HelloWorld MIDlet that you have compiled, do the following:
9 4. In the Windows Command Prompt, use the mkdir command to create a directory into
which the preverifier tool should output the classes created in compiling the MIDlet. Enter the
following command:

10 mkdir C:\classes

11 5. Use the cd command to switch to the \bin subdirectory of the directory where you
installed the SDK. Enter, for example, the following command:

12 cd C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\bin

13 6. Preverify the Hello World MIDlet classes by entering the following command:

14 preverify -d c:\classes -classpath C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\lib\*.zip


C:\tmpclasses

Before running the compiled and preverified HelloWorld MIDlet, you need to package the
MIDlet.
7.8 Packaging the Hello World MIDlet

As distributed, a MIDlet consists of a Java archive (JAR) file and a Java Application Descriptor
(JAD) file. The JAR file contains a manifest, a special file that contains metainformation about the
files in the JAR file.

7.9 Creating the manifest file

A manifest is a text file located in the JAR file. The manifest describes information about the
MIDlets in the JAR file.

To create a manifest, do the following:


15 1. In the Windows Command Prompt, change to the classes subdirectory where the
preverifier created the verified class files. Enter, for example, the following command:

16 cd C:\classes

17 2. Create the MANIFEST.MF file by entering, for example, the following command:

18 edit MANIFEST.MF

19 3. The manifest file opens in the editor. Enter the following information into the manifest
file that you are creating:
20 4. Select File > Save to save the edited MF file.
21 5. Select File > Exit to close the editor.

22 MIDlet-<m> Attribute, where <m> is an integer, starting at 1 and incremented by 1 for


each MIDlet, contains up to tree pieces of information:
23 • MIDlet name
24 • Icon for this MIDlet (optional). For example, /images/hello.png
25 • Classname the application manager will call to load the MIDlet

7.10 Creating the application JAR File

Here is a simple example of using the JAR.EXE utility to build a JAR file:
26 1. In the Windows Command Prompt, change to the classes subdirectory where the
preverified class files are located and where you created the MANIFEST.MF file. Enter, for
example, the following command:

27 cd C:\classes

28 2. Create a JAR file named HelloWorldMIDlet.jar which includes the manifest file, the
MIDlet classes and the resource files. Enter, for example, the following command:

29 jar -cmf MANIFEST.MF HelloWorldMIDlet.jar


com\series80\examples\lcdui\helloworld\*.class

The JAR tool creates the file HelloWorldMIDlet.jar to the classes subdirectory.

Creating the JAD file


30 1. In the Windows Command Prompt, still in the classes subdirectory, create a JAD file
named HelloWorldMIDlet.jad by entering, for example, the following command:

31 edit HelloWorldMIDlet.jad

32 Note: Make sure that you use the extension .jad in the file.

2. The file opens in the editor. Enter the following information into the JAD file that you are creating:
3. Select File > Save to save the edited JAD file.
4. Select File > Exit to close the editor.

33 Make sure that at least all mandatory attributes and their values in the JAD file are typed
correctly and that they are in the right format. The attributes and values of the JAR package’s
manifest file must be correct as well. The best way to ensure that is to use a packaging tool, for
example, Nokia Developer’s Suite for J2ME™. With this tool it is easy to set and update attibutes
and values into both the JAD and manifest file.

Check at least the following:


34 • All mandatory attributes and their values in the JAD file and the JAR package are correct.
35 • The application descriptor contains the attributes specified in MIDP 2.0 specification. It
must contain at least the following attributes: MIDlet-Name, MIDlet-Version, MIDlet-Vendor,
MIDlet-Jar-URL and MIDlet-Jar-Size. Make sure that you enter the exact byte size of the file as
the MIDlet-Jar-Size.
36 • Data reported in the JAD file is consistent with the information reported within the
application. The best way to ensure this is to request the getAppProperty()method of the MIDlet
class when this kind of information is needed. The getAppProperty()method retrieves the
requested information from the JAD file or the JAR package’s manifest file. For example,
getAppProperty(“MIDlet-Version”)returns the version of the MIDlet.
37 • The maximum JAR file size should not exceed the limit of downloadable applications so
that the application can be installed over-the-air (OTA) too. In many end user cases the
application is installed using over-the-air download. The network operators have their own limits
for the downloadable applications. Check the maximum limit from the network service provider
and ensure that the application size is smaller than that.

38 Now that you have created the package MIDlet, you can run and view it in the emulator.

7.11 Running the HelloWorld MIDlet in the emulator

To run the HelloWorld MIDlet in the emulator, do the following:


39 1. In the Windows Command Prompt, use the cd command to switch to the bin\
subdirectory of the directory where you installed the SDK. Enter, for example, the following
command:

40 cd C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\bin

41 2. Run the Hello World MIDlet in the emulator by entering the following command in the Command Prompt:

42 emulator -Xdescriptor:C:\classes\HelloWorldMIDlet.jad

The emulator appears on the screen and displays the Hello World string:

Figure 5: Hello World MIDlet in the emulator


The emulator works like a real Nokia 9500 Communicator: To simulate pressing buttons on a real
device, click the corresponding keys on the emulator with the mouse.

In this section you have compiled and preverified the Hello World MIDlet, and also seen what the
Hello World MIDLet would look like in a real phone. The next step would be to install it to a
target device. The installation procedure is covered in the next section.

7.12 Installing your application on device


Installing the MIDPlet involves deploying the application package file (JAR file) and Java
Application Descriptor (JAD file) files, which you created in the previous section to your device.
Follow the instructions provided in the user manual on how to install new applications as the
installation procedure varies depending on the device.

The file transfer can be done through various channels depending on your PC, for example using
Bluetooth, Infrared or USB cable. The steps below provide two examples on how to install a
MIDlet to your Nokia 9500 Communicator.

7.13 Deployment with Wireless Link

43 Note: You must have built-in IrDa hardware and Infrared and Wireless Link installed on
your computer. If you do not have built-in IrDA, see your computer manual for more details on
how to install an Infrared and Wireless Link.
44 1. Make sure that the infrared ports of the sending and receiving devices are pointing at
each other.
45 2. Activate the infrared port on the Nokia 9500 Communicator and wait until the infrared
icon on the Windows status bar appears (until the infrared connection between the PC and
phone has been activated).
46 3. Open the Windows Explorer on your PC and browse to the directory where the
application file is located.
47 4. Select the .jad and .jar files.
48 5. Click the right mouse button on top of the selected file and select Send to > Infrared
Recipient. The application files are sent to your device via Infrared. Your phone should receive
the installation files as a message attachment.
49 6. Go to the messaging folder in your device and open the transferred installation file. If
requested, confirm the installation command and follow the wizard to complete the installation
process. A notification is displayed when the installation is complete.

7.14 Deployment with PC Suite Application Installer

50 Note: This deployment method requires that the Nokia PC Suite 6.4 is installed on your
computer. Previous versions of PC Suite may also be used but they require additional installation
of the Nokia PC Connectivity Cable Drivers. More information can be found from
http://www.nokia.com/pcsuite.
51 1. Make sure that your phone is configured for PC Suite connection: Tools > Control Panel
> Connections > Cable setup > Data cable mode should be changed to PC Suite Connection.
52 2. Connect your Nokia 9500 Communicator to the PC either with Nokia Connectivity Cable
DKU-2 or via infrared port.
53 3. Right-click on Nokia PC Suite icon from system tray and select Nokia Application
Installer.
54 4. The Nokia 9500 device should appear in the My Phone list. If the device is not present,
click the Select a phone button, choose the Nokia 9500 device and click OK. In the case the phone
is not shown in Phone Selector window, check the connection.
55 5. In the My Computer list, browse to the folder where you have stored installation file.
Select the file and click the Install button.
56 6. Finish the installation by following the Application Installer wizard.

7.15 Using the SDK with Nokia Developer's Suite 2.2 for J2ME™

7.16 Installation and configuration

Series 80 Developer Platform 2.0 SDK for Symbian OS – For MIDP is installed and configured
automatically when Nokia Developer’s Suite for J2ME™ is installed. You can also add and remove
the SDK manually:

57 1. Start the IDE where the Nokia Developer’s Suite is integrated or start Nokia Developer’s
Suite for J2ME™ as stand-alone.

58 2. Select Tools > Nokia Developer’s Suite for J2ME > Configure Emulators… from the IDE
menu. In the stand-alone version, select Emulators > Configure Emulators… The Configure
Emulators dialog opens.
59
Figure 6: Configure Emulators dialog

60 3. The emulator should be visible in the Emulators list. If it is not visible, choose Add… and
select the directory you installed the SDK. The default MIDP SDK home path is
C:\Nokia\Devices\S80_DP2_0_MIDP_SDK. Push Open to accept.
61 4. The properties of the selected emulator device are displayed in the tool. As the SDK
contains only one device, it is selected automatically as the default emulator device.

62 Note: Note that a emulator may contain one or more devices. If there is more than one
device you can configure each one individually. Change currently selected device from the Select
default device combo box. This combo box is not displayed for Series 80 MIDP SDK, the emulator
contains just one device.

63 5. Select the emulator and choose Set as default. The emulator is now set as default MIDP
SDK for this project.

64 6. Push Close to accept.

65 To remove Series 80 MIDP SDK from Nokia Developer’s Suite for


J2ME™
66 1. Open the Configure Emulators dialog by selecting Emulators > Configure…
67 2. Select Series 80 MIDP SDK from the Emulators list.
68 3. Click the Remove button.

69 Note that this only removes the emulator from Nokia Developer's Suite 2.2 for J2ME™ tool
set. The actual uninstallation of the emulator must be done with the Series 80 Developer
Platform 2.0 SDK for Symbian OS – For MIDP's own uninstallation procedure. If the SDK/emulator
has not been uninstalled it can be reloaded to Nokia Developer's Suite 2.2 for J2ME™ with Add...
button.

7.17

7.18 Development
Start Emulators tool allows you run a MIDlet directly from the local file system.

The stand-alone installation of Nokia Developer's Suite 2.2 for J2ME™ does not include tools for
editing, compiling or debugging the MIDlet classes, you must use third party tools and a Java™
SDK for these purposes. The other option is to install Nokia Developer's Suite 2.2 for J2ME™
integrated with an IDE such as Borland ® JBuilder™, Sun™ ONE Studio or Eclipse platform, which
provide the tools for editing, compiling and debugging MIDlets .
When you have successfully installed and configured the Series 80 MIDP SDK, you can start
developing MIDlets and running them on the SDK:
70 1. Create or open a MIDlet project as defined in Nokia Developer’s Suite for J2ME™ User’s
Guide [4]
71 2. To start the emulator, in IDE select Tools > Nokia Developer’s Suite for J2ME > Start
Emulators… In stand-alone version press Start Emulators on the panel.
72 3. Browse the application to be started.
73 4. Select the emulator from the Emulators list.
74 5. Click the Emulate button to start the application. Emulators execute the MIDP
Application file described in the text field when you press Emulate. If running with class, a
warning will appear if any of the selected devices do not support that feature. All devices are
executed in their own processes so they do not share the same instance of the application.

75 To run the MIDlet Suite examples.jad included with the Series 80 MIDP SDK, browse to
directory C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\Series80ex\bin, select the example.jad and
press Emulate.
Figure 7: Running Series 80 examples.jad from Nokia Developer's Suite

The following MIDlet selector dialog is shown:


Figure 8: MIDlet selector

Select the MIDlet to run and press Enter. The MIDlet launches on the Series 80 MIDP SDK
Emulator.

Messages from the Series 80 emulator are displayed in a message window.

7.19 Using the SDK with Borland® JBuilder®9

7.20 Installation and configuration

Before you can specify the SDK to be used in your JBuilder project, you have to add it to the set
of available Java Development Kits (JDKs). Follow the instructions in the JBuilder help menu
under MobileSet Guide to configure the emulator as a JDK to be used in application
development. The JDK directory to select is the root directory of this SDK.

Complete the following steps to set up a new JDK in Borland JBuilder 9.


76 1. Start JBuilder and select Tools > Configure JDKs… from the main menu. The Configure
JDKs dialog opens as follows:
77
Figure 9: Jbuilder JDK configuration

78 2. To add the SDK to the list, click New… The New JDK Wizard opens.
79
Figure 10: New JDK Wizard

80 3. In the Existing JDK home path: field, browse to the SDK installation directory and select
it. The Series 80 MIDP SDK is displayed in the Name for this JDK field.
81 4. Click the drop-down arrow and select a storage location for the JDK specifications library
file. The available locations varies by JBuilder editions, see JBuilder Help for details.
82
Figure 11: Series 80 MIDP SDK in JDK Wizard

83 5. Click OK.
84 6. In the Configure JDKs dialog, select SDK from the tree view.
85
Figure 12: Configure JDK

86 7. From the JDK Settings, select the Micro tab. S80_DP2_0_MIDP_SDK should now be
shown as the Target Device.

87
88 8. Click OK.

89 To set the SDK as the JDK in your project, do as follows:


90 1. Start JBuilder and select Project > Project Properties… from the Main menu.
91 2. If the Series 80 MIDP SDK is not displayed in the JDK: field, click and select the Series
80 MIDP SDK from the tree
92 3. Click OK to accept.

7.21
7.22

7.23

7.24 Development

The Series 80 Developer Platform 2.0 SDK for Symbian OS – For MIDP can be used to develop and
run MIDlets. The SDK is able to run applications packaged into a MIDlet Suite, as specified in the
MIDP specification, or directly from a MIDlet class. When you are running a MIDlet suite, both a
JAD file (Java Application Descriptor) and a JAR file need to be created before the application can
be run. For general instructions on creating MIDlet Suites, see the MobileSet Guide in JBuilder.
Users of JBuilder Personal Edition need to use the Nokia Developer’s Suite for J2ME(TM) to
create the JAD and JAR files.

For more infomation on how to develop, build and run applications using JBuilder, see the User’s
Guide and the Example Applications section in the SDK Help and the Jbuilder documentation.

Complete the following tasks before attempting to run the application:


93 1. Select the correct JDK to be used for building and running the application by selecting
Tools > Configure JDKs… and change the JDK Home Path to point to the Series 80 MIDP SDK’s
installation directory.
94 2. Select Project > Project Properties...
95 3. Select the Paths tab and make sure that the Series 80 MIDP SDK is selected as the JDK to
be used for building and running the application.
96
Figure 13: Default project properties

You can add optional Emulator parameters for the Runtime Configuration by selecting Project >
Project Properties... Select the Run tab and select Edit…

If you are using the Professional or Enterprise Edition of Borland JBuilder and the Achive builder
(JAR tool) that comes with them, the JAR file is automatically updated in the build process.

With JBuilder Personal Edition and Nokia Developer’s Suite for J2ME(TM), it is important to
‘Recreate’ the JAD and JAR files before running the application. Otherwise the emulator will run
the old version of these files instead of using the newly compiled classes.

Once the MIDlet class and/or MIDlet suite has been created, they can be run by using the
MicroRun feature. Select a MIDlet class or the JAD from the project pane and then select Run >
MicroRun.

7.25 Debugging with Borland JBuilder 9

When you have installed and configured the SDK properly you can start using the debugging
features in Borland JBuilder. To start debugging, select the MIDlet class or the JAD file from the
project pane and select Run | Micro Debug. If you have defined breakpoints in the content pane,
code execution will stop when a breakpoint is reached.

Instead of Borland JBuilder’s internal debugger you can also use third-party debuggers, or you
can use the JBuilder debugger as an external debugger when executing MIDlets outside of
Borland JBuilder (that is from the Wireless Toolkit or the command-line).

To edit the debug properties of Borland JBuilder:


97 1. Open a MIDlet project and set Nokia Communicator MIDP SDK as the JDK used in your
MIDlet project.
98 2. Select Run > Configurations... The Project Properties dialog opens.
99 3. Select the Run tab.
100 4. Select the configuration from the Runtime Configurations list and select Edit… The
Runtime Configuration Properties dialog opens.
101 5. Select the Debug tab to see the debug properties of the configuration.
102
Figure 14:JBuilder’s debug properties for the runtime configuration

To use Borland JBuilder’s debugger as an external debugger for an SDK launched from outside
the JBuilder, see Chapter 14.3 “Debugging from the command-line”

In order to use Borland JBuilder as an external debugger for the SDK, you must select the
following options:
103 1. Enable remote debugging by checking the appropriate check box.
104 2. Select Attach.
105 3. Check that the Transport Type value is “dt_socket.”
106 4. Set the port in the Address field of the Debug tab to match with the debugger port
defined in the SDK’s start-up command.
107 5. Start the emulator with -Xdebug and -Xrunjdwp parameters as described in Chapter 14.3
“Debugging from the command-line”
108 6. Start the debugger by choosing Run > Micro Debug from the JBuilder menu.

7.26 Using the SDK with Borland® JBuilder®X

7.27 Installation and configuration


Before you can specify the SDK to be used in your JBuilderX project, you have to add it to the set
of available Java Development Kits (JDKs). Follow the instructions in the JBuilderX help menu
under MobileSet Guide to configure the emulator as a JDK to be used in application
development. The JDK directory to select is the root directory of this SDK.

Complete the following steps to set up a new JDK in Borland JBuilderX.


109 1. Start JBuilderX and select Tools > Configure JDKs… from the main menu. The Configure
JDKs dialog opens as follows:
110
Figure 15: JBuilderX JDK configuration

111 2. To add the SDK to the list, click New… The New JDK Wizard opens.
112
Figure 16: New JDK Wizard in JBuilderX

113 3. In the Existing JDK home path: field, browse to the SDK installation directory and select
it. The Series 80 MIDP SDK is displayed in the Name for this JDK field.
114 4. Click the drop-down arrow and select a storage location for the JDK specifications library
file. The available locations varies by JBuilderX editions, see JBuilderX Help for details.
115
Figure 17: Series 80 MIDP SDK set as new JDK

116 5. Click OK.


117 6. In the Configure JDKs dialog, select SDK from the tree view.
118
Figure 18: JDK configuration dialog

119 7. From the JDK Settings, select the Micro tab. The should now be shown as the Target
Device. Click OK.
120
Figure 19: Micro tab in JDK configuration

You can specify the SDK as the default JDK as follows:


121 1. Start JBuilderX and select Project > Default Project Properties…
122 2. On the Paths tab, click the button next to the JDK: field. The Select a JDK dialog is
opened.
123 3. Select the Series 80 MIDP SDK from the list.
124 4. Click OK to accept.

125 To set the SDK as the JDK in your project, do as follows:


126 1. Start JBuilderX and select Project > Project Properties…
127 2. If the Series 80 MIDP SDK is not displayed in the JDK: field, click and select the Series
80 MIDP SDK from the tree.
128 3. Click OK to accept.
7.28 Development
The Series 80 Developer Platform 2.0 SDK for Symbian OS – For MIDP can be used to develop and
run MIDlets. The SDK is able to run applications packaged into a MIDlet Suite, as specified in the
MIDP specification, or directly from a MIDlet class. When you are running a MIDlet suite, both a
JAD file (Java Application Descriptor) and a JAR file need to be created before the application can
be run. For general instructions on creating MIDlet Suites, see the MobileSet Guide in JBuilderX.
Users of JBuilderX Personal Edition need to use the Nokia Developer’s Suite for J2ME(TM) to
create the JAD and JAR files.

For more infomation on how to develop, build and run applications using JBuilderX, see the
User’s Guide and the Example Applications section in the SDK Help and the JbuilderX
documentation.

Complete the following tasks before attempting to run the application:


129 1. Select the correct JDK to be used for building and running the application by selecting
Tools > Configure JDKs… and change the JDK Home Path to point to the Series 80 MIDP SDK’s
installation directory.
130 2. Select Project > Project Properties...
131 3. Select the Paths tab and make sure that the Series 80 MIDP SDK is selected as the JDK to
be used for building and running the application.
132
Figure 20: Default project properties in JBuilderX

You can add optional Emulator parameters for the Runtime Configuration by selecting Project >
Project Properties... Select the Run tab and select Edit…

If you are using the Professional or Enterprise Edition of Borland JBuilderX and the Achive builder
(JAR tool) that comes with them, the JAR file is automatically updated in the build process.

With JBuilderX Personal Edition and Nokia Developer’s Suite for J2ME(TM), it is important to
‘Recreate’ the JAD and JAR files before running the application. Otherwise the emulator will run
the old version of these files instead of using the newly compiled classes.

Once the MIDlet class and/or MIDlet suite has been created, they can be run by using the
MicroRun feature. Select a MIDlet class or the JAD from the project pane and then select Run >
MicroRun.

7.29

7.30

7.31 Debugging with Borland JBuilderX


When you have installed and configured the SDK properly you can start using the debugging
features in Borland JBuilderX.

To start debugging, select the MIDlet class or the JAD file from the project pane and select Run |
Micro Debug. If you have defined breakpoints in the content pane, code execution will stop when
a breakpoint is reached.

Instead of Borland JbuilderX´s internal debugger you can also use third-party debuggers, or you
can use the JBuilderX debugger as an external debugger when executing MIDlets outside of
Borland JBuilderX (that is from the Wireless Toolkit or the command-line).

To edit the debug properties of Borland JBuilderX:


133 1. Open a MIDlet project and set Nokia Communicator MIDP SDK as the JDK used in your
MIDlet project.
134 2. Select Run > Configurations... The Project Properties dialog opens.
135 3. Select the Run tab.
136 4. Select the configuration from the Runtime Configurations list and select Edit… The
Runtime Configuration Properties dialog opens.
137 5. Select the Debug tab to see the debug properties of the configuration.

138
Figure 21:JBuilderX’s debug properties for the runtime configuration

To use Borland JBuilderX’s debugger as an external debugger for an SDK launched from outside
the JBuilderX, see Chapter 14.3 “Debugging from the command-line”

In order to use Borland JBuilderX as an external debugger for the SDK, you must select the
following options:
139 1. Enable remote debugging by checking the appropriate check box.
140 2. Select Attach.
141 3. Check that the Transport Type value is “dt_socket.”
142 4. Set the port in the Address field of the Debug tab to match with the debugger port
defined in the SDK’s start-up command.
143 5. Start the emulator with -Xdebug and -Xrunjdwp parameters as described in Chapter 14.3
“Debugging from the command-line”
144 6. Start the debugger by choosing Run > Micro Debug from the JBuilderX menu.

7.32 Using the SDK with Sun J2ME™ Wireless Toolkit 2.1

7.33 Installation and configuration


The emulator appears automatically in Sun J2ME™ Wireless Toolkit 's device list if it has been
installed into the <WTK_home>\wtklib\devices directory, for example, C:\WTK20\wtklib\devices

To check that the Sun J2ME™ Wireless Toolkit has recognized the SDK as a target device:

Open KToolbar from the installed Wireless Toolkit menu.The SDK should be displayed in the
Device drop-down list.
Figure 22: Series 80 MIDP SDK configured in Wireless Toolkit

If the Series 80 MIDP SDK is not displayed on the list, carry out the following steps:
145 1. Install, or copy an already installed, Series 80 MIDP SDK to the
<WTK_home>\wtklib\devices folder. For example, C:\WTK21\wtklib\devices
146 2. Open Ktoolbar.
147 3. When the Series 80 MIDP SDK is installed to the correct location, it will be displayed in
the Device list and can be started. If the SDK has been installed somewhere else, you must copy
the entire emulator directory to the device directory.

148 Having now configured the emulator, you are ready to start with application development.
For further instructions, see Example Applications in the SDK Help.

Development
J2ME Wireless Toolkit has the following bugs/features that affect the building and running
procedures of the application:
149 • The build process uses the class library of the previously selected device before the Run
button is pressed. After you have attempted to run the application, the build process will start
using the correct library until the selected device is changed again.
150 • The build process does not automatically refresh the MIDlet JAR package after building
the application. Choose Project > Package > Create Package from the menu to refresh the JAR
package before running the application.

151 Proceed as follows:


152 • After selecting the device, click Run before attempting to Build. (It does not matter if
running fails in this phase.)
153 • After building, choose Project > Package > Create Package before attempting to Run.

154 About the Preferences window:

The clean database utility of J2ME Wireless Toolkit has no effect on this emulator. The only way
to clean up the RMS database of the emulator is to manually delete the application-generated
content of the “appdb” directory.

7.34 Debugging with the Sun J2ME Wireless Toolkit


Wireless Toolkit does not provide an internal debugger and therefore an external debugger is
required. For further information on using an external debugger, see Chapter 14.3, “Debugging
from the command-line”
155 1. Open a MIDlet project in the Wireless Toolkit and set S80_DP2_0_MIDP_SDK as the
current device.
156 2. Choose Project > Debug from the Wireless Toolkit’s menu. The Remote debugging port
dialog opens.

157
Figure 23: Wireless Toolkit’s Remote debugging port dialog

158 3. Enter the Remote debugging port in the text field (e.g. 5000) and click the Debug button
to put the SDK in debug wait state.
159 4. Launch an external debugger to connect the SDK to the debug port: jdb -connect
com.sun.jdi.SocketAttach:hostname=localhost,port=5000

160 The debugger is connected to the SDK’s debug port when you see the text “Connection
received” in the SDK’s prompt. Type help in the debugger prompt to see the available debugger
commands. The run command starts MIDlet execution.

7.35

7.36

7.37

7.38

7.39

7.40 Using the SDK with Sun Java Studio Mobility 6 2004Q3
The emulator integrates into Sun Java Studio Mobility 6 2004Q3 either via J2ME Wireless Toolkit
(WTK) or via UEI.

To integrate via WTK, you must have the J2ME WTK and Sun Java Studio installed, and the
emulator must be installed into directory <WTK home directory>\wtklib\devices.

7.41 Installation and configuration


To integrate the emulator into Sun Java Studio, complete the following steps:
161 1. Start Sun Java Studio and select the Runtime tab from the mounted file systems view.
162 2. Open the Device Emulator Registry node and browse to the Installed Emulators node.
163 3. Add the SDK by clicking the right mouse button on the Installed Emulators node and
then select Add Emulator…
164 4. Select the directory where the SDK was installed and click Add. The SDK is now
displayed under the Installed Emulators.
165 5. Browse to the SDK and right click to select it. Select Set As Default from the pop-up
menu.
166 6. Next, you need to check that the SDK is set as the default emulator as follows: Navigate
to the Device Emulator Registry node and then to the Default Emulators node under it. Check
that the SDK you chose previously has been set as default.

167 For more information see chapter Emulator Installation from document “Technical
Articles: Introduction to Sun Java Studio Mobility 6” [5].

You can assign the SDK as your default emulator by selecting the SDK with the right mouse
button and choosing Set as default from the pop-up menu.

7.42

7.43

7.44 Development
Complete the following tasks before attempting to run the application:
168 1. In the Sun Java Studio´s File menu, select Mount Filesystem…
169 2. Select Local Directory from the New Wizard dialog and click Next.

170
Figure 24: New Wizard dialog
171
172
173
174
175
176
177 3. Select src folder of selected example and click Finish.

178
Figure 25: New Wizard – Local Directory

179 4. Build the project by pressing “F11” or by selecting Project > Build Project from the
menu.
180 5. Start the application by pressing “F6” or by selecting Build > Execute from the menu.

181 See the document 'Technical Articles: Introduction to Sun Java Studio Mobility 6 [5] for
instructions on how to use Sun Java Studio 6 Mobility to develop MIDlets.

7.45

7.46

7.47

7.48
7.49

7.50

7.51 Debugging with the Sun Java Studio Mobility 6


To use debugger in Sun Java Studio Mobility 6:
182 1. To create a MIDlet Suite, select example folder in File Systems (right click) and from pop-
up menu select New > MIDlet suite.

183
Figure 26: Create new MIDlet Suite

184
185
186
187 2. Add new object name to the next dialog.
188 3. From Add MIDlet dialog select Use Existing MIDlet and click browse.

189

Figure 27: Add MIDlet dialog

190
191
192
193
194
195
196
197
198
199 4. Select MIDlet for this example and click OK.

200
Figure 28: Choose MIDlet class dialog

201 5. Click Next and enter MIDlet´s name and icon and click Finish.
202 6. In the Sun Java Studio’s Explorer window, select the MIDlet suite or source code to
execute and to assign a breakpoint, click the right mouse button on source code line and choose
Toggle breakpoint from the popup menu..
203 7. Choose Debug > Start Session > Run in Debugger or press Alt+F5.

204 The Sun Java Studio will switch to the Debugging workspace and launch the SDK to Debug
process. The execution will stop when a breakpoint is reached.
205 Note: Use only one mounted file system for the MIDlet suite when debugging your MIDlet.
Series 80 MIDP SDK supports only one source folder at a time. Files added to any other folders
are not recognized.

7.52

7.53 Using the SDK with IBM® WebSphere® Studio Device Developer

7.54 Installation and configuration


The Series 80 Developer Platform 2.0 SDK for Symbian OS – For MIDP has been designed for
integration with the IBM® WebSphere® Studio Device Developer (WSDD). The integration is done
automatically if you have WSDD installed on the computer when installing Series 80 MIDP SDK. If
you have installed WSDD after installing Series 80 MIDP SDK, you have to install the metadata
files manually, for more information, see [2].

206 Note: Debugging on Series 80 MIDP SDK emulator is not supported with IBM ® WebSphere®
Studio Device Developer.

7.55 Starting the IBM® WebSphere® Studio Device Developer for the first time

The first time you start the WSDD after you installed the Series 80 MIDP SDK, you are informed of
a new “Series 80 Developer Platform 2.0 SDK for Symbian OS, For J2ME MIDP” plug-in.
Figure 29: Configuration changes pending

Click Finish. You are asked to restart WSDD to take the plug-in into use.

Figure 30: Restart WSDD after installing plug-in

207 Note: If the WSDD does not inform you about the new plug-in and you have installed
Series 80 MIDP SDK to other directory than the default C:\Nokia\Devices\S80_DP2_0_MIDP_SDK,
you need to edit the correct SDK path to file C:\Program
Files\IBM\DeviceDeveloper\eclipse\links\ com.ibm.ive.S80_DP2_0_MIDP_SDK.link

7.56 Configuring as a UEI Emulator Device


A device configuration must be created using the Unified Emulator Device selection in the WSDD
IDE. You need to configure the device before you can run MIDlets with Series 80 MIDP SDK
emulator.
208 1. Select Configure… from the Devices… menu or click Device on the WSDD toolbar.

209
Figure 31: Create and manage device configurations

210 2. Select UEI Emulator Device from the list and click New.
211
Figure 32: New UEI Emulator Device

212 3. In the Device Configurations dialog, edit the Device name field. To complete the
Emulator root directory field, click Browse to search the file system, then select the installed
Series 80 MIDP SDK main directory (C:\Nokia\Devices\S80_DP2_0_MIDP_SDK)

213
Figure 33: Configured Series 80 MIDP SDK device
214 4. Click OK.

7.57 Development

7.58 Creating a new MIDlet Suite

One or more MIDlets can be packaged into a MIDlet suite. Do the following to create a MIDlet
suite:
215 1. Start WSDD and select File > New Project

216
Figure 34: New project in WSDD
217
218
219
220
221
222 2. Select J2ME and MIDlet Suite.

223
Figure 35: J2ME MIDlet suite selected

224
225
226
227
228 3. Click Next.

229
Figure 36: MIDlet Suite Creation

230 4. Enter the name of the suite to be created. Select the MIDP version. In the appropriate
field, enter the name of the MIDlet, the name of the package, and name of the MIDlet class. Click
Finish.

7.59 Importing examples to the MIDlet suite


You can use the Import Wizard to copy files from a file system directory into the WSDD IDE.
231 1. From the WSDD main menu bar, select File > Import. The Import wizard opens.

232
Figure 37: Import dialog

233
234 2. Select File System and click Next.
235
Figure 38: Import from file system

236 3. Click the Browse button to select the directories from which you would like to add the
files.
237 4. Select the Series 80 example directory
C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\Series80Ex and press OK.
238
Figure 39: Importing Series 80 examples

239 5. Select the files you want to add. Expand the hierarchies in the left pane and select or
clear the checkboxes that represent the folders in the selected directory. Then in the right pane,
select or clear checkboxes for individual files. When you have finished specifying your import
options, click Finish.

7.60 Launching a MIDlet in the Series 80 Emulator


You must create a launch configuration in WSDD the first time you run a MIDlet suite on the
Series 80 Emulator. The executable will run on the local platform with the J9 virtual machine and
the Series 80 Emulator.
240 1. Select the MIDlet project and then select the Run.. command from the Run menu.

241
Figure 40: Run configurations

242
243
244
245
246
247 2. In the Run configurations dialog, select MIDlet suite from the list and click New.
248
Figure 41: New MIDlet Suite configuration

249 3. In the Run dialog, edit the run configuration fields. To complete the Project field, click
Browse to set the project. Set the configured “Series 80 MIDP SDK Emulator” to the Device or
JRE field.
250
Figure 42: Series 80 MIDP SDK set as a device

251 4. Select the MIDlet suite examples.jad to be run using the combo box. Click Run. The
following MIDlet selector dialog is shown:

252
Figure 43: MIDlet selector

253 5. Select the MIDlet to run and press Enter. The J9 VM and the MIDlet launches on the
Series 80 MIDP SDK Emulator.
254
Figure 44: MIDlet running on Series 80 SKD emulator

The emulator allows you to view and test MIDlets on your PC before installing them on a real
device. It provides a graphical interface of a real Nokia 9500 Communicator and device
functionality to test your MIDlet.

255 Note: If your MIDlet does not respond to commands, you can kill your MIDlet using the key
combination Shift + Ctrl + Alt + K, which kills the application with the current keyboard focus.

256 You can reuse a previously created run configuration to run your MIDlet suite:
257 1. Click Run > Run.
258 2. In the Run dialog box, select a run configuration from the Configurations list.
259 3. Click Run.

Using the SDK with Eclipse 3.0


The emulator integrates into Eclipse 3.0 via Nokia Developer’s Suite for J2ME™ Version 2.2 for
Windows.

7.61 Installation and configuration

Nokia Developer’s Suite for J2ME™ Version 2.2 for Windows integrates automatically with Eclipse
3.0 if you choose the correct install set when Nokia Developer’s Suite is istalled.

Figure 45: Eclipse selected during Nokia Developer's Suite installation


Figure 46: Eclipse root directory

Select the root directory of the Eclipse IDE in the file system and continue the installation of
Nokia Developer’s Suite for J2ME™ Version 2.2 for Windows.

If you need to install the integration manually, do the following:

Copy the following folders from


C:\Nokia\Tools\Nokia_Developers_Suite_for_J2ME_2_2\bin\eclipse to Eclipse's root folder
C:\testing_tools\eclipse-SDK-3.0-win32\eclipse:

/features
/com.nokia.phone.tools.midp.ide.eclipse_1.0.0
/com.nokia.phone.tools.sdk.plugin.eclipse_1.0.0

/plugins
/com.nokia.phone.tools.designer_1.0.0
/com.nokia.phone.tools.midp.ide.eclipse_1.0.0
/com.nokia.phone.tools.sdk.plugin.eclipse_1.0.0
7.62 Setting Java Debug Preferences
When debugging MIDlets on Series 80 MIDP SDK emulator device, it is necessary to turn off some
debugger preferences. To do so:
260 1. Select from the Eclipse menu Window > Preferences.
261 2. Then select Java > Debug from the preferences tree.
262 3. Clear Suspend execution on uncaught exceptions, Suspend execution on compilation
errors and Suspend for breakpoints during evaluation.
263 4. Increase timeout values to prevent debugger timing out before the debugged MIDlet
has started. We recommended that you increase the debugger timeout to 50,000 when
debugging with Series 80 MIDP SDK.

264
Figure 47: Java Debug settings for Eclipse 3.0
7.63 Development
In this chapter we go through the tasks needed to create a MIDP application with the Series 80
Developer Platform 2.0 SDK for Symbian OS – For MIDP using the example application delivered
with the SDK.

7.64 Create a new project

To be able to create a new project for Series 80 Developer Platform SDK, carry out the following
steps:
265 1. Select File >New >Project in the Java Perspective.

266
Figure 48: New project in Eclipse

267
268
269
270
271
272 2. Select Java > MIDP Project (Nokia SDK Plug-in) and click Next

273
Figure 49: new MIDP project

274 3. Enter the name for the project. If you choose a directory for the Project content, make
sure the project name is the same as the name of the content directory. Click Next to continue.

275
Figure 50: SDK selection wizard in Eclipse

276 4. Select the SDK you wish to use for compiling and preverifying the MIDP project. If the
SDK is not displayed in the drop-down list, click Browse… and select the root directory of the SDK.
Click Next to continue.
277
Figure 51: MIDP settings in Eclipse

278 5. Make sure that the project source folder in build path and default output folders are set
correctly. Click Finish.

279 Note: Use only one source folder for your MIDlet if you are using Nokia Developer’s Suite
for J2ME™ Version 2.2 for Windows for creating packages in Eclipse. Nokia Developer’s Suite for
J2ME™ Version 2.2 for Windows supports only one source folder at a time. Files added to any
other folders are not recognized.

7.65

7.66 Import example code to project


280 1. Click right mouse button on src-folder in Navigator window.
281 2. Select File > Import from the menu. The following dialog opens:
282
Figure 52: File import dialog in Eclipse

283
284
285
286
287 3. Select File System and click Next.
288
Figure 53: Import src from the file system

289 4. Import src directory and browse the Into folder setting and click Finish.

7.67

7.68

7.69

7.70 Building application


Select from the menu: Project > Build Project
or set Project > Build Automatically.

Running application in emulator

When you wish to run the source of a MIDlet class in the Series 80 MIDP SDK Emulator, select the
class in one of the following ways:
290 • Select the class’ .java file in the Package Explorer
291 • Select the .jad file in the Package Explorer
292 • Select the project that includes the MIDlet in the Package Explorer
293 • Open the MIDlet in the editor

294 Then choose Run > Run As > Nokia SDK. This will create a launch configuration for the
MIDlet. The Series 80 MIDP SDK Emulator starts up.

You can edit the launch configuration. Choose Run > Run… The dialog for creating, managing, and
running configurations opens. Select a launch configuration under Nokia SDK Plug-in in the
configurations list.

Debugging a MIDlet

When you want to debug an existing MIDlet with the Series 80 MIDP SDK, select a configuration
you want to debug in one of the following ways:
295 • Select the class’ .java file in the Package Explorer
296 • Select the .jad file in the Package Explorer
297 • Select the project that includes the MIDlet in the Package Explorer
298 • Open the MIDlet in the editor

299 Add breakpoints to the MIDlet. Select to debug the configuration, for example from Run >
Debug as > Nokia SDK. The Debug perspective opens in the Eclipse.

To modify configuration settings, choose Run > Debug… The dialog for creating, managing, and
running configurations open.
Using the SDK from the command-line

The emulator can also be used from the command-line. As an alternative to standard command-
line syntax you can also use Unified Emulator Interface (UEI) syntax.

7.71 Standard command-line syntax

java -classpath <path> -Demulator.home=<emulator root dir> com.nokia.phone.sdk.Emulator


[options] -Xdescriptor <file>

Manifest-Version: 1.0
MicroEdition-Configuration: CLDC-1.0
MIDlet-Name: HelloWorldMIDlet
MIDlet-Vendor: MyCompany
MIDlet-1: HelloWorldMIDlet, , com.nokia.examples.lcdui.helloworld.HelloWorldMIDlet
MIDlet-Version: 1.0
MicroEdition-Profile: MIDP-2.0

MIDlet-Version: 1.0
MIDlet-Vendor: MyCompany
MIDlet-Jar-URL: HelloWorldMIDlet.jar
MicroEdition-Configuration: CLDC-1.0
MIDlet-1:HelloWorldMIDlet,
,com.nokia.examples.lcdui.helloworld.HelloWorldMIDletMicroEdition-Profile: MIDP-2.0
MIDlet-Jar-Size: 1276
MIDlet-Name: HelloWorldMIDlet

Option Description
- help Shows emulator help.
- version Shows emulator version.
- http_proxy Specifies the HTTP proxy to be used for networking.
<host>:<port>
- debugger Runs the application with debugging enabled.
- dgb_port <port> Specifies the TCP/IP port to be used between the debugger and
the debug proxy. By default, the emulator assigns the first
unnallocated port starting from 2810.
- port <port> Specifies the TCP/IP port to be used between the VM and the
debug proxy. By default, the emulator assigns the first
unallocated port starting from 2810.
- classpath <path> Specifies the directories and JAR files to be searched for classes.
You may include both library and application class directories
and JAR packages.
- Xdescriptor <file> Specifies the name of the JAD file to be used for finding the JAR
| -jad <file> file to execute. This name must always be specified. The
following rules will be used for searching for the JAR file:
(1) If the JAD contains the entry for MIDlet-Jar-URL, and
(1.1) If the URL is a relative file URL, look for the JAR file using
the location of the JAD file as reference.
(1.2) If the URL is an absolute file URL, look for the JAR file using
the absolute path.
(2) If the JAD file does not contain the entry for the MIDlet-Jar-
URL, search from the classpath.

The KVM debug proxy that is required for source level debugging will be started automatically
when the emulator is started in debug mode from the command-line.

8 UEI command-line syntax

emulator [arguments] <Application>


Argument Description
-classpath, -cp The class path for the
VM.
-D<property=value> Property definitions.
-version Displays the
emulator’s version
information.
-help Displays the list of
valid arguments.
-Xverbose[: allocation | gc | gcverbose | class | classverbose Enables verbose
| verifier | stackmaps | bytecodes | calls | callsverbose | output.
frames | stackchunks | exceptions | events | threading |
monitors | networking | all ]
-Xquery Query options.
-Xdebug Enables the remote
debugger.
-Xrunjdwp:[transport=<transport>, Debugging options.
address=<address>,server=<y/n> suspend=<y/n>]
-Xdevice:<device name> Name of the device to
be emulated.
-Xdescriptor:<jad file name> The JAD file to
execute.
-Xjam[:install=<jad file url> | force | list | storageNames | Java Application
run=[<storage name> | <storage number>] | Manager and support
remove=[<storage name> | <storage number> | all] for Over The Air
provisioning (OTA).
-Xheapsize:<size> Specifies VM heapsize
(e.g. 65536 or 128 KB
or 1 MB).
To run the examples from the command line, do the following:
1 1. Use the cd command to switch to the \bin subdirectory of the directory where you
installed the SDK. Enter, for example, the following command:

cd C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\bin

1 2. Type the following command to run examples included with the SDK:

emulator -Xdescriptor:C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\Series80ex\bin\exam ples.jad

The following MIDlet selector dialog is shown:

Figure 54: MIDlet selector dialog

1 3. Select the MIDlet to run and press Enter.

Debugging from the command-line

To debug the execution of an application launched from the command-line, you need an external
debugger. You can use the Java Debugger included in the Java Development Kit by Sun
Microsystems. Alternatively, you can use Borland JBuilder’s debugger as the external debugger.
See Chapter 8.3, “Debugging with Borland JBuilder” for further information on how to use the
JBuilder debugger.
Basic steps for debugging:
1 1. Start the SDK in debugging mode. The easiest way to do this is to use emulator.exe in
the bin directory of the MIDP SDK:

2 emulator.exe -Xdebug -Xrunjdwp:transport=dt_socket,address=4452, server=y


-Xdescriptor:C:\WTK21\apps\UIDemo\bin\UIDemo.jad

This puts the SDK debugger connection in wait state. The SDK waits for the debugger connection
to port 4452.
1 2. Launch the debugger to connect with the SDK:

3 jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=4452

The debugger is connected to the SDK’s debugger port when you see the text “Connection
received” in the SDK’s prompt.
1 3. Start debugging:

4 The run command starts MIDlet execution. Type help in the debugger prompt to see the
available debugger commands.

8.1 Media content emulation


Mobile Media API enables you to use the media recording capabilities included in the phone. This
chapter explains how these features are emulated in the Series 80 Developer Platform 2.0 SDK
for Symbian OS – For MIDP.

9 Camera
You can use the getSnapshot method in javax.microedition.media.control.VideoControl to get a
snapshot. The SDK uses the files located in the camera directory in the SDK’s installation
directory for camera emulation. You can change the files presented in the figure below to suit
your needs but remember to maintain the aspect size and format of the images.
Figure 55: Viewfinder and snapshot images in supported capture formats

Audio Recording

You can record live audio with the Series 80 Developer Platform 2.0 SDK for Symbian OS – For
MIDP using a microphone and Mobile Media API. You should test that your microphone is
working properly before using the SDK for audio recording purposes. If you do not have a
microphone you can set Stereo Mixing or Line in as your audio source. In Windows the recording
options are available in the Recording Control dialog box.

Integration with Other Nokia Products

The Series 80 MIDP SDK installation package includes the Nokia Connectivity Framework (NCF)
Lite version. You can use NCF to communicate with other Nokia Terminal SDKs and Nokia
products that support NCF connectivity.

NCF manages, configures and integrates products so that they can communicate with each other.
NCF provides an integration platform for delivering content data in mobile development
environment between the connected external software components, for example phone
emulators, content development tools, software development tools and server emulators.

NCF Lite is installed with the Series 80 MIDP SDK installation by default and it provides
communication environment with Bluetooth, SMS and MMS technologies. NCF Lite can emulate
Bluetooth hardware; you can use Bluetooth messaging in the Series 80 MIDP SDK Emulator
without having Bluetooth hardware installed.

NCF Full version provides support for hardware components, such as Nokia D211 and Bluetooth
cards. It contains a full communication environment with features like run-time communication
monitoring and visualization of environments. You can download NCF Full version from the
Forum Nokia website.

10 Getting started

NCF starts automatically when you log onto a Windows workstation. When NCF is started, the
Nokia Connectivity Framework -icon appears on the system tray.
Figure 56:Nokia Connectivity Framework icon on the system tray

You can start NCF manually by selecting Windows Start > Programs > Nokia Developer Tools >
Nokia Connectivity Framework > Nokia Connectivity Framework Lite

To shut down NCF service, click the icon on the system tray and select Shutdown.

1 Note: The startup link for NCF is located in Windows Start > Programs > Startup menu. You
can remove this automatic start-up by deleting the program shortcut.

11 Communicating with other Nokia products


Start products/emulators/tools/servers - from the windows menu or using commands in the
console window i.e. any way that is suitable for starting the product normally. NCF automatically
detects and configures communication between started Nokia products that support NCF
connectivity.

NCF uses phone numbers, which can be used to send messages between started emulators. To
check the phone numbers of started products, click the NCF service icon on the system tray. A
pop-up menu shows the product names and phone numbers.

2 Note: Wait a couple of seconds before checking the phone numbers because the phone
number initialization takes a while.

2
Figure 57: Series 80 MIDP SDK’s phone numbers in Nokia Connectivity Framework pop-up menu

Each pop-up menu item shows phone numbers for technologies that the product supports. Use
this phone number when sending messages. For example, use number 55512351, shown in the
figure, to send MMS messages to the Series 80 MIDP SDK emulator. You can send a MMS
message as you would in real phone.

Figure 58: Sending a MMS message

You can edit, reply to, or forward received messages with the emulator. When you select Send,
the emulator saves the sent message in the
C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\bin\epoc32\Wins\c\msgout directory and sends it via
NCF.

The Series 80 MIDP SDK accurately simulates the receipt of a message, as the user of a Nokia
9500 Communicator device would experience it.
Figure 59: Receiving a MMS message

How to configure NCF integration

Each product configures NCF communication automatically when the product is installed. You
should not need to make additional configurations unless you change the product installation
manually.

To add new products to work with NCF you just have to install NCF compatible products on your
computer. Products need to be installed in their default location or the home directory has to be
configured from the product properties in the NCF product integration files.

It is strongly recommended that the NCF configuration should be made using the configuration
features in NCF FULL version.

If you want to configure product properties, it is done by modifying product integration xml-files
from the product’s NCF integrations directory. By default, you’ll find the Series 80 MIDP SDK
integration files in the directory:
C:\Nokia\Tools\Nokia_Connectivity_Framework\integrations\Series_80_DP_2.0_SDK_for_Symbi
an_OS_For_MIDP

For example:
1 • To change the Series 80 MIDP SDK product home directory (that sets value for the
environment variable _PRODUCT_HOME) modify
Series_80_DP_2.0_SDK_for_Symbian_OS_For_MIDP.xml
2 • To change the SMS Inbox, make your changes to
Series_80_DP_2.0_SDK_for_Symbian_OS_For_MIDPSMSFileHandler.xml
3 • MMS Outbox in modified in
Series_80_DP_2.0_SDK_for_Symbian_OS_For_MIDPMMSFileHandlerServer.xml
4 • To change VCOM port settings (* used with Bluetooth communication, modify
Series_80_DP_2.0_SDK_for_Symbian_OS_For_MIDPVCOMServer.xml

You need to restart the NCF after the configurations in order to take the new settings into use.

5 Note: (* To enable Bluetooth when you use NCF, you need to set the COM port in
C:\Nokia\Devices\S80_DP2_0_MIDP_SDK\bin\epoc32\wins\c\System\Data\bt.esk to be same as
VCOM setting in Series_80_DP_2.0_SDK_for_Symbian_OS_For_MIDPVCOMServer.xml file.
12 Documents included with Series 80 Developer Platform SDK

The Series 80 Developer Platform SDK Help provides information and instructions needed when
working with the Software Development Kit to create new Nokia 9500 Communicator
applications with C++.

Besides general documents such as this User’s Guide, the Series 80 Developer Platform
SDKcontains a wide range of documentation:
6 • Symbian OS Developer Library, the guide and reference for Symbian OS with Series 80
API documentation containing:
7 o API Guides - purpose and description for each API
8 o API Reference
9 o Guides for Nokia Tools and Utilities

10 • Device-specific documents and feature documentation.


11 • Documents that explain issues related to platform independent software development.
12 • Porting guides to ease application porting between different platforms.
13 • Technical documentation and guides to enable hardware specific features in the Series
80 Developer Platform SDK

13 Forum Nokia
Forum Nokia is the Nokia support forum for developers using its technologies and is found at
http://www.forum.nokia.com/

14 Java
As the Java technology was created by Sun technologies Inc., a good place to find comprehensive
introductions to Java is the java.sun.com (http://java.sun.com /) website, and its wireless pages
(http://developers.sun.com/techtopics/mobility/ ) in particular.

14.1 Terms and Abbreviations


Term or Meaning
abbreviation
API Application Programming Interface
Canvas A low-level UI component of LCDUI
CBA The Command Button Area (CBA) on the right of the Series 80 device
Application area correspond to buttons to access key commands or
functions within an application.
CLDC Connected Limited Device Configuration
Displayable An LCDUI object that has the capability of being placed on display.
IDE Integrated Development Environment
J9 VM IBM’s J9 Virtual Machine
JAD Java Application Descriptor
JAM Java Application Manager. A MIDP system component used for
managing MIDP applications on a mobile device.
JAR Java Archive. A single file (.jar) format that includes the required class
and resource files for one or several applications.
JDK Java Development Kit
JSR Java Specification Request
LCDUI Limited Capability Device User Interface. An UI toolkit in MIDP.
MAC address A standardized data link layer address that is required for every port
or device that connects to a LAN.
MIDP Mobile Information Device Profile.
MMS Multimedia Message Service
NCF Nokia Connectivity Framework enables SMS, MMS and Bluetooth
message routing between Nokia phone emulators, content
development tools, software development tools and server
emulators.
OTA Over-the-Air
Screen A subclass of the Displayable class. The Screen is an abstract
superclass for all high-level UI components in MIDP LCDUI.
SDK Software Development Kit
SMS Short Message Service
UEI A generic, unified emulator interface (UEI) that allows IDE
manufacturers to write to a single interface and to be able to support
different emulators.
UI User Interface
USB Universal Serial Bus (USB) is a plug-and-play interface between a
computer and add-on devices.
WLAN A Wireless LAN is one in which you can connect to a local area
network through a radio connection.

WMA The Wireless Messaging Api (WMA) is an optional package for J2ME
that provides platform-independent access to wireless
communication resources like Short Message Services (SMS).
WTK The Java 2 Platform, Micro Edition (J2ME) Wireless Toolkit is a
development enviroment for developing Java applets and
applications.
Before Writing MIDlet Application
http://www.forum.nokia.com/Technology_Topics/Development_Platforms/Java.xhtml

I need an SDK. Which is the right one for my phone?


Most current Nokia devices that offer Java technology are based on either the Series 40 platform
or Symbian. Within each platform, there are various editions and feature packs. Editions
represent significant updates in functionality, such as moving from MIDP 1.x to MIDP 2.x. Feature
packs are incremental improvements within an edition, adding, for example, new JSRs or
improving the supported features within an existing JSR. Each combination of platform, edition,
and feature pack has its own SDK.

To find out which platform, edition, and feature pack your device uses, consult the Forum Nokia
Device Specifications pages and check the ‘Developer Platform’ section of the technical
specifications.

Once you’ve determined which platform your device uses, you can download the SDK for the
relevant feature pack and SDK.

Download the latest S60 platform SDKs that support Java™ development »
Download the Series 40 platform Java SDKs »

If you’re new to Java development, you’ll also need a Java™ Development Kit (JDK) — either JDK
6 or JDK 5.0.

Download a JDK »
I can build an application on a PC, but how do I get it onto a phone?
Although you develop Java™ applications on a PC, the goal is to run them on a Nokia device. Two
simple steps will help you do this.

First, download Nokia PC Suite, which provides a wealth of connectivity and


synchronisation options.

Download Nokia PC Suite »

If you’ve chosen to develop with NetBeans Mobility, you now have the option
to use the NetBeans deployment module to transfer your application to a
device connected to your PC directly from NetBeans. (Open your project’s properties and look
for the Deploying option.) If you’re using another IDE, you can deploy your applications using the
Install Applications option in PC Suite.

If you have any query:

Adnan Fakhar

velocitykhan@yahoo.com

Вам также может понравиться