Introduction to J2ME
Presented By:
Contents
What’s J2ME?
Java Editions
J2ME core concepts
Configurations (CLDC, CDC)
Profiles (MIDP)
MIDP and MIDlets
Basic Classes API
Java Technology Carriers
Java Technology Handsets
Overall Evaluation
J2ME 2
Introduction
Personalized and intelligent information
appliances are necessities in our life today.
Such appliances can be:
cell phones
two-way pagers
smart cards
personal organizers
palmtops
These appliances tend to be special-purpose,
limited-resource, network-connected devices.
J2ME 3
Environment requirements
We need an environment which is adapted
for constrained devices - devices that have
limitations on what they can do when
compared to standard desktop or server
computers.
The constraints are:
extremely limited memory
small screen sizes
alternative input methods
slow processors
J2ME 4
At the JavaOne Conference in June 1999,
Sun Microsystems announced a new edition
of the Java 2 platform: the Java 2 Micro
Edition (J2ME).
J2ME 5
Java Editions
Different devices have different
requirements and different expectations of
Java.
One platform (solution) cannot address all
the market segments (web server, video
games etc.)
Users/developers want flexibility. They
want to choose what they want to use and
what they do not.
J2ME 6
Java Editions
The Java 2 Platform is split into three
editions.
Each edition provides a complete
environment for running Java-based
applications, including the Java virtual
machine (VM) and runtime classes.
The three editions target different kinds of
applications running on different kinds of
devices.
J2ME 7
Java Editions
Java 2 Platform
Java2 Java2 Java2
Standard Edition Enterprise Edition Micro Edition
(J2SE™) (J2EE™) (J2ME™)
Standard desktop & Heavy duty server Small & memory
workstation applications systems constrained devices
J2ME 8
Java Editions
Each edition defines different sets of
class libraries.
There are thousands of core J2SE
runtime classes, taking up to 10-20
megabytes
of space. J2EE
J2ME-based devices have J2SE
fewer classes.
J2ME
J2ME 9
Java Family
What is J2ME
J2ME is a family of specifications that
defines various downsized versions of the
standard Java 2 platform; these downsized
versions can be used to program consumer
electronic devices ranging from cell phones
to highly capable Personal Data Assistants
(PDAs), smart phones, and set-top boxes.
---J2ME in a Nutshell –
A Desktop Quick Reference
By
Kim Topley
PersonalJava and EmbeddedJava
J2ME is not the first attempt at adapting
Java for constrained environments.
PersonalJava
EmbeddedJava
J2ME 12
Sun Microsystems’ Web site
describes J2ME this way:
. . . Java 2 Platform, Micro Edition is a highly
optimized Java runtime environment
targeting a wide range of consumer
products, including pagers, cellular phones,
screenphones,digital set-top boxes and car
navigation systems.
J2ME 13
J2ME Core Concepts
J2ME is based on 3 core concepts:
Configurations
Profiles
Optional packages
J2ME 14
J2ME Category
Principle: Different hardware corresponds different JVMs, hardware which base on CDC have
powerful JVMs, and hardware which base on CLDC have KVM to support.
J2ME Model
Configurations
A configuration is a complete Java
runtime environment, consisting of:
Java virtual machine (VM) to execute
Java bytecode
Native code to interface to the
underlying system
Set of core Java runtime classes
To use a configuration, a device must
meet certain minimum requirements.
J2ME 16
Configurations
The set of core classes is normally
quite small and must be enhanced
with additional classes supplied by
J2ME profiles or by configuration
implementor.
Configurations do not define any user
interface classes.
J2ME 17
Configurations
Configuration
CLDC CDC
Connected Limited Connected Device
Device Configuration Configuration
J2ME 18
Connected Device Configuration (CDC)
Device requirements: A connected device (CD)
has a minimum 512KB of ROM, 256KB of RAM,
32-bit processors, and some network
connection with limited bandwidth
CDC is designed for "more powerful" wireless
devices like TV set-top boxes, car navigation
systems, and high-end PDAs.
CDC specifies that a full-featured Java Virtual
Machine (JVM) (defined in J2EE) is supported
19
Connected, Limited Device
Configuration (CLDC)
Covers mobile devices like mobile phones, PDAs,
pagers, and other "tiny" wireless devices
For smaller devices than CDC, with limited capacity
and network connection
For devices with 160KB to 512 KB of memory
available for Java platform
For devices with limited power supply
Built on "scale-down" version of JVM called KVM
(Sun 'K Virtual Machine, with size in tens of
kilobytes, rather than JVM with tens of megabytes)
20
J2ME Core Concepts
J2ME is based on 3 core concepts:
Configurations
Profiles
Optional packages
J2ME 21
Profiles
Adds domain-specific classes to a
configuration:
To fill in missing functionality
To support specific uses of a device
Most profiles define user interface classes
for building interactive applications.
To use a profile, the device must meet the
minimum requirements of the underlying
configuration and of the profile.
J2ME 22
Profiles
Profile
MIDP PDAP FP PBP PP
Mobile Personal Foundation Personal Personal
Information Digital Profile Basis Profile Profile
Device Assistant
Profile Profile
J2ME 23
MIDP – MID Profile
MIDP is targeted at a class of devices
known as mobile information devices
(MIDs).
Minimal characteristics of MIDs:
Enough memory to run MIDP applications
Display of at least 96 X 56 pixels, either
monochrome or color
A keypad, keyboard, or touch screen
Two-way wireless networking capability
J2ME 24
MIDP - Specification
The MIDP adds APIs to the basic APIs defined by
the CLDC. The new features include:
Support for application lifecycle management similar
to the way applets are defined in J2SE.
Persistent storage of data.
HTTP-based network connectivity based on the
CLDC's GCF.
Simple user interface support, with enough flexibility
to build games or business applications.
J2ME 25
MIDP - Specification
The MIDP specification is silent about
a number of things:
No standard way to interface to the
device's phonebook, in order to initiate
voice calls.
How MIDP applications are loaded onto a
device and how they are activated or
deactivated.
J2ME 26
MIDP Applications restrictions
Memory is a particularly scarce resource.
The early Motorola J2ME-enabled phones limited
the size of an application to 50K. Some Nokia
phones limit them to even less, about 30K.
MIDP 1.0 applications cannot share classes.
Placing part of the application in a web or
application server (as a servlet, typically)
that the MIDP application calls is almost a
requirement for anything serious.
J2ME 27
MIDP API
(familiar packages)
java.io
java.lang
java.lang.ref
java.util
MIDP API
(no so familiar packages)
javax.microedition.io
javax.microedition.lcdui
javax.microedition.lcdui.game
javax.microedition.media
javax.microedition.media.control
javax.microedition.midlet
javax.microedition.pki
javax.microedition.rms
MIDP and MIDlets
MIDP enables application development with mobile, wireless-
connected devices like cellular phones and two-way pagers
Main features of the supported devices:
small displays
limited input devices
limited local storage
limited battery life
limited CPU power
MIDlets:
Small applications that run under the MIDP are called MIDlets
A MIDlet is a Java application that uses the MIDP and the CLDC
In a mobile phone, application management software (AMS)
controls start, stop and execute MIDlet (controls the entire
lifecycle)
Device manufacturer provides the AMS Software
30
MIDlet states
31
MIDlets – The heart of J2ME…
Every application must extend
javax.microedition.midlet.MIDlet
class to allow the application
management software to:
control the MIDlet
be able to retrieve properties from the
application descriptor
notify and request state changes
J2ME 32
J2ME Core Concepts
J2ME is based on 3 core concepts:
Configurations
Profiles
Optional packages
J2ME 33
Optional Packages
Set of APIs in support of additional,
common behaviors.
Have specific dependencies on a particular
configuration and/or one or more profiles.
Examples of optional packages :
RMI Optional Package
Bluetooth Optional Package
JDBC Optional Package
J2ME 34
What it all means
"J2ME application" is an ambiguous term.
Configuration, profile and optional
packages should be chosen.
CDC-based profiles make development
simpler due to J2SE-like APIs, but don’t suit
the low-end devices.
CLDC-based profiles makes the
development task harder, especially when
trying to shrink the size of the application
to run on many of the small devices.
J2ME 35
Java Technology
Carriers
Java Technology
Handsets
To date, over 250 different handset models from more than 40 manufacturers
have been developed with Java technology, with more than 100 million of these
handsets shipped worldwide.
Overall Evaluation
Advantages
Easy to learn
Learning J2ME is like learning Java programs
Platform independent
The layering architecture of the J2ME
programming model allows MIDlets
(applications for mobile devices) to run on
different mobile devices (Java systems).
Build on top of an operating system and
All lower levels components are hided by the
OS
Overall Evaluation
Integration with other Java
components
Can build complex mobile applications
using with least effort by integration with
other Java components
Good for security-oriented applications,
which use cryptographic classes
Can build wireless Internet applications
Overall Evaluation
Limitations
Accessing device resources
Multimedia applications
Performance-intensive applications
Overall Evaluation
There are more than 2.1 billion Java ME
enabled mobile phones and PDAs, but it is
becoming old technology as it is not used
on any of today's newest mobile platforms
(eg iPhone, Android, Windows Phone 7,
MeeGo, BlackBerry's new QNX).
Getting Started…
1st step: Download sun’s J2ME
Wireless Toolkit from:
http://java.sun.com/products/j2mewtool
kit/download-2_1.html
2nd step: Make sure you have J2SE
SDK installed
3rd step: Install the J2ME Toolkit.
J2ME 42
Thanks