Lecture 4 3 J2ME
Lecture 4 3 J2ME
Mobile Ecosystem
Mobile application frameworks
Java 2 Micro Edition
Configurations and profiles
Optional packages
Generic connection framework
Application manager and MIDP applications
Sun Java ME SDK 3.0
Two examples of Midlets
The Mobile Ecosystem
Services
Applications
Application Frameworks
Devices
Networks
Operators
Operators
Germany, United
GSM, GPRS, EDGE,
7. T-Mobile States, United 126.6
UMTS, HSDPA
Kingdom, Poland…
Norway, Sweden, GSM, GPRS, EDGE,
8. TeliaSonera 115.0
Denmark, Finland… UMTS, HSDPA
France, United
GSM, GPRS, EDGE,
9. Orange Kingdom, Switzerland, 111.8
UMTS, HSDPA
Poland, Spain…
Russia, Ukraine,
GSM, GPRS, EDGE,
10. MTS Belarus, Uzbekistan, 91.7
UMTS
Turkmenistan,..
Afghanistan, Benin,
Botswana, Cameroon, GSM, GPRS, EDGE,
11. MTN Group 80.7
Republic of Congo, UMTS, HSDPA, HSUPA
Côte d’Ivoire, …
Networks
Second generation of mobile phone Theoretical max data
2G
standards and technology speed
Global System for Mobile
GSM 12.2 KB/sec
communications
GPRS General Packet Radio Service Max 60 KB/sec
limit
f: clock frequency, can be reduced temporally
Loss of data
higher probability, has to be included in advance into
the design (e.g., defects, theft)
Limited user interfaces
compromise between size of fingers
and portability
integration of character/voice
recognition, abstract
symbols
Limited memory and
computing power
Computers for the next decades?
Computers are integrated
small, cheap, portable, replaceable
Technology is in the background
computer are aware of their environment and adapt (“location
awareness”)
computer recognize the location of the user and react
appropriately (e.g., call forwarding, fax forwarding, “context
awareness”))
Advances in technology
more computing power in smaller devices
flat, lightweight displays with low power consumption
new user interfaces due to small dimensions
more bandwidth per cubic meter
multiple wireless interfaces: wireless LANs, wireless WANs,
regional wireless telecommunication networks etc. („overlay
networks“)
The Mobile Ecosystem
Services
Applications
Application Frameworks
Operating Systems -
Platforms
Devices
Networks
Operators
Mobile Operating Systems - Platforms
http://wiki.forum.nokia.com/index.php/
Application Frameworks (IV)
The Web
The only application framework
that work across all devices and
operating systems
Applications are built using web
standards
WML
XHTM-MP
Java script
CSS
Optional Packages
J2ME
Profiles
Profile
J2ME
Libraries
Configuration
Java Language
17 packages
J2SE
CDC CLDC
Profile and Optional Packages
The profile adds classes to a configuration:
To fill in missing functionality
To support specific uses of a device
To address the specific demands of a vertical market
sector, e.g., cellular telephones, washing machines,
electronic toys
The Optional Packages are set of APIs that support
additional and common behaviors
Examples of optional packages:
Bluetooth Optional Package
JDBC Optional Package
File connection
Personal Information Management (PIM)
Location API
Profiles
Memory:
256Kb non-volatile for MIDP components (in
addition to the requirements of CLDC),
8Kb non-volatile for application created
persistent data,
128 Kb volatile for virtual machine run
time
Display: 96x54, depth 1-bit, pixel shape
1:1
Input: either keypad, or keyboard, or touch
screen
Networking: two-way, intermittent, with limited
bandwidth
Sound: play tones.
Software Requirements: MIDP
javax.microedition.lcdui java.lang
javax.microedition.lcdui.game java.lang.ref
javax.microedition.media java.io
javax.microedition.media.control java.util
javax.microedition.midlet javax.microedition.io
javax.microedition.pki
javax.microedition.rms
Latest MIDP2.1 has minor differences with 2.0: making LCDUI layout
directive mandatory, javax.microedition.io.SocketConnection and
javax.microedition.io.HTTPConnection is no longer optional
Devices Evolution (Nokia)
MIDP 2.0
CLDC 1.1
Advanced Multimedia
MIDP 2.0 MIDP 2.0 Supplements (JSR-234)
CLDC 1.0 CLDC 1.1 Bluetooth API (JSR-82)
Bluetooth API (JSR-82) FileConnection and PIM API
Bluetooth API
(JSR-82 No OBEX) FileConnection and PIM API (JSR-75)
(JSR-75) JTWI (JSR-185)
Mobile Media API
(JSR-135) JTWI (JSR-185) Location API (JSR-179)
Nokia UI API Mobile 3D Graphics API Mobile 3D Graphics
Wireless Messaging API (JSR-184) API (JSR-184)
(JSR-120) Mobile Media API Mobile Media API (JSR-135)
(JSR-135) Nokia UI API
Nokia UI API Scalable 2D Vector
Web Services API Graphics API
(JSR-172) (JSR-226)
Wireless Security and Trust Services API
Messaging API (JSR-177)
(JSR-120) SIP API (JSR-180)
Web Services API (JSR-172)
Wireless Messaging API
(JSR-205)
What device?
If you want to know what devices support what profile/
configuration/package go to the WTK3.0 and the
select "Tools>Device Database Search"
It is based on WURFL
The WURFL is an "ambitious" configuration file that
contains info about all known Wireless devices on earth
http://wurfl.sourceforge.net
Or go to http://www.forum.nokia.com/devices/
CLDC 1.1. Class Library
Connection
StreamConnection UPDDatagramConnection
HttpsConnection
Summary
MIDlets – The heart of J2ME
MIDP does not run in the “regular” Java fashion using:
main (), System.exit()
Instead, we use MIDlet applications - which are
subclasses of javax.microedition.midlet.MIDlet
The application must extend this class to allow the
application management software to control the MIDlet:
control the MIDlet installation
Inspect existing Java applications stored on the device
be able to retrieve properties from the application
descriptor
Select and launch Java applications; respond to a
request for state change
Delete existing applications
A CLDC system may allow multiple Java applications to
executes concurrently (MIDP2.1) or restrict to one
application at a time (MIDP2.0).
MIDP Application Lifecycle
pauseApp
does not want to be active and has entered the
startApp
Paused state
Active
destroyApp
The AM has called startApp()
The midlet has called resumeRequest(): indicate Active
that it is interested in entering the active state
destroyApp
Destroyed
The AM or the midlet has called destroyApp():
signals the MIDlet to terminate and enter the
destroyed state
notifyDestroyed(): the midlet notifies the AM
that has entered the destroyed state.
Destroyed
MIDlet Suite
One or more MIDlets are packaged together into a MIDlet
suite, composed of:
JAR (Java archive) file
Contains Java classes for each MIDlet in the suite
and Java classes that are shared between MIDlets
Contains resource files (e.g. an image) used by the
MIDlets and a manifest file
JAD (Java Application Descriptor) file
Contains a predefined set of attributes that allows the
device application management software to identify,
retrieve, and install the MIDlets
Can be modified after packaging (and signing)
Eventually the JAR / JAD files are uploaded to the device
in order to run the application.
Wireless Development Tutorial Part I
What do we need
Java Platform, Standard Edition version 1.5 or
higher
Sun Java Micro Edition SDK This is a package of
tools for building and testing MIDlets
Text editor. This can be something as
rudimentary as Notepad (on Windows) or
something more elaborate (IDE environment as
NetBeans)
Following example is from
http://developers.sun.com/techtopics/mobility/
midp/articles/wtoolkit/
http://developers.sun.com/techtopics/mobility/
midp/articles/tutorial2/
Java ME SDK
Download the Java ME SDK 3.0 from
www.oracle.com/technetwork/java/javame/
Execute the installation file
There is a very good user guide
Project
Uncheck
this
2
HelloWorld MIDlet
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloMIDlet
extends MIDlet
implements CommandListener {
private Form mMainForm;
public HelloMIDlet() {
mMainForm = new Form("HelloMIDlet");
mMainForm.append(new StringItem(null, "Hello, MIDP!"));
mMainForm.addCommand(new Command("Exit", Command.EXIT,
0)); mMainForm.setCommandListener(this);
}
HitMIDlet.URL: http://localhost:8080/midp/hits
MIDlet-1: Hellosuite, Hellosuite.png, HelloMIDlet
MIDlet-2: HitMIDlet, , HitMIDlet
MIDlet-Jar-Size: 3016
MIDlet-Jar-URL: Hellosuite.jar
MIDlet-Name: Hellosuite
MIDlet-Vendor: Unknown
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
Connection with a Servlet
Install NetBeans
Remember at the beginning of the installation to
choose “customize” installation and deselect
GlassFish and select Tomcat
We need to develop simple Web applications
based on servlets
Create a new java web project with the servlet
shown in the next slide
HitServlet
import javax.servlet.http.*; code
import javax.servlet.*;
import java.io.*;
response.setContentType("text/plain");
response.setContentLength(message.length());
PrintWriter out = response.getWriter();
out.println(message);
}
}
MIDLET
import java.io.*;
import javax.microedition.io.*;
code
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public HitMIDlet() {
mMainForm = new Form("HitMIDlet");
mMessageItem = new StringItem(null, "");
mExitCommand = new Command("Exit", Command.EXIT,
0); mConnectCommand = new Command("Connect",
Command.SCREEN, 0);
mMainForm.append(mMessageItem);
mMainForm.addCommand(mExitCommand);
mMainForm.addCommand(mConnectCommand);
mMainForm.setCommandListener(this);
}
MIDLET cont.
public void startApp() {
mDisplay = Display.getDisplay(this);
mDisplay.setCurrent(mMainForm);
}
try {
hc = (HttpConnection)Connector.open(url); in
= hc.openInputStream();
in.close();
hc.close();
After 4 clicks on
the ‘connect’
command
MIDP 3.0 (still a JSR -complete)
JSR 271: Mobile Information Device Profile 3
Enable multiple concurrent MIDlets in one VM
Specify proper firewalling, runtime behaviors, and lifecycle management
issues for MIDlets
Enable background MIDlets (e.g. UI-less)
Enable ?auto-launched? MIDlets (e.g. started at platform boot time)
Enable inter-MIDlet communications
Enable shared libraries for MIDlets
Improve UI expressability and extensibility
Better support for devices with larger displays
Enable MIDlets to draw to secondary display(s)
Enable richer and higher performance games
Secure RMS stores
Removable/remote RMS stores
IPv6
Multiple network interfaces per device
Specify standard ways for doing MIDlet provisioning through other means
(e.g. OMA (SyncML) DM/DS, Bluetooth, removable media, MMS, JSR-232,
etc.)
Extensive device capabilities query
Localization & Internationalization
http://java.sun.com/developer/technicalArticles/javame/midp3_enhanc
e/
Exercises
F. Ricci