Java ME On Symbian OS
Java ME On Symbian OS
JAVA ME ON SYMBIAN OS
Secure your route to market
Symbian Signed is an industry-backed scheme
that allows Symbian OS software developers to
obtain a digital signature for their applications.
To be ‘Symbian Signed’ applications must pass
various standardised tests. Some network
operators and phone manufacturers (e.g. Orange,
Nokia and Sony Ericsson) now require that C++
and AppForge MobileVB/Crossfire applications
must be signed if they are to be distributed
through their channels.
JAVA ME ON SYMBIAN OS
from
Java ME on Symbian OS
part of the Using Symbian OS series
1st edition, 12/06
Published by:
Symbian Software Limited
2-6 Boundary Row
Southwark
London SE1 8HP
UK
www.symbian.com
Contents
What do I need?..................................................................5
Introduction
Mobile Java is one of the most widely installed runtimes
on mobile phones. By enabling rich, advanced data
services (for instance, location-based services and
wireless commerce) it has gained recognition as a solid
revenue stream for operators and content providers.
Java platforms
A Java platform is a software-only platform that runs on
top of a native platform, this being the combination of
the operating system and the underlying hardware.
A Java platform is divided into two components:
• The JVM that executes the Java language bytecode –
this can be ported to various native platforms.
• The collection of Java APIs - ready-made software
libraries that provide programming capabilities.
Together, the JVM and APIs insulate an application from
the native platform.
3
What do I need?
First of all, you will need development software to help
you to write the code and compile it. This is best done
6
You can download and run the NetBeans IDE 5.0 Installer
from www.netbeans.org/community/releases/50. When the
installation completes, you can download and run the
NetBeans Mobility Pack 5.0 In staller from the same URL.
You now have an IDE for Java ME application
development.
SDKs:
• S60 Platform SDKs for Symbian OS, for Java
www.forum.nokia.com/main/resources/tools_and_sdks
/listings/java_tools.html
• Carbide.j
www.forum.nokia.com/main/resources/tools_and_sdks
/carbide/index.html
8
• UIQ3.0
www.developer.uiq.com/devtools_uiqsdk.html
• SEMC SDK for the Java ME platform
www.developer.sonyericsson.com/site/global/docstool
s/java/p_java.jsp
• WTK
www.java.sun.com/products/sjwtoolkit
import javax.microedition.midlet.MIDlet;
import
javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
/**
* Hello, World example
*/
9
/**
* Exit command
*/
private Command iExitCommand;
/**
* MIDlet constructor
*/
public HelloWorld() {
iExitCommand = new Command("EXIT",
Command.EXIT, 1);
}
/**
* Signals the MIDlet that it has entered
the Active state.
*/
public void startApp() {
TextBox textBox =
new TextBox("Hello World", "Hello,
World!", 256, 0);
textBox.addCommand(iExitCommand);
textBox.setCommandListener(this);
Display.getDisplay(this)
10
.setCurrent(textBox);
}
/**
* Signals the MIDlet to enter the Paused
state.
*/
public void pauseApp() {
}
/**
* Signals the MIDlet to terminate and enter
the Destroyed state.
*/
public void destroyApp
(boolean aUnconditional) {
}
/**
* Indicates that a command event has
occurred on a Displayable.
*/
public void commandAction(Command aCommand,
Displayable aScreen) {
if (aCommand == iExitCommand) {
notifyDestroyed();
}
}
}
11
import
implements CommandListener
public HelloWorld() {
iExitCommand = new Command("EXIT",
Command.EXIT, 1);
}
• a label
• a type
• a priority.
“textBox.addCommand(iExitCommand);”
“textBox.setCommandListener(this);”
“Display.getDisplay(this).setCurrent(textBox);”
“notifyDestroyed();”
The MIDlet notifies the AMS that it has entered into the
Destroyed state.
Please note that in a more complex example a MIDlet
must perform the same cleanup and releasing of
resources it would have done if the MIDlet.destroyApp()
had been called by the AMS.
Launch NetBeans from the Start menu. Select ‘File’ -> ‘New
Project’. A Project Wizard page will be displayed. In the
‘Categories’ panel, select ‘Mobile’ and in the ‘Projects’
panel, select ‘Mobile Application’, then hit ‘Next’.
You will be presented with ‘Name and Location’ page in
which you can tick the ‘Create Hello MIDlet’, which will
auto-generate a similar HelloWorld MIDP application.
19
Now click ‘Finish’. The IDE will create a basic ‘Hello World’
project for you. This should appear in the ‘Projects’ view
of the IDE. If you expand the project folder, you will be
able to see the contents. Click on the ‘Source’ tab and
the source file will be displayed in the main editor view
of the IDE.
Developer Resources:
Symbian Developer Network
http://developer.symbian.com
S60 forum
www.forum.nokia.com/main/resources/technologies/java
http://developer.symbian.com
Symbian OS Explained
by Jo Stichbury
Symbian OS Internals
by Jane Sales
Also from
Published Booklets
Coding tips
Signing tips
Performance Tips
Essential UIQ - Getting Started
Getting started
Translated Booklets
JAVA ME ON SYMBIAN OS
Symbian Press
Symbian Press publishes books designed to
communicate authoritative, timely, relevant and
practical information about Symbian OS and related
technologies. Information about the Symbian Press
series can be found at
http://developer.symbian.com/main/academy/press