J2ME: Introduction, Configurations and Profiles: Keywords: Java 2 Micro Edition (J2ME), PDA, Configuration, CDC, CLDC

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

J2ME: Introduction, Configurations and

Profiles
Urs Steiner
University of Zürich
urs@darkstone.ch

Abstract
A small presentation of the topics of Java 2 Micro Edition (J2ME) by Sun
Microsystems, configurations and profiles. For customer and embedded
systems, including mobile devices, J2ME provides a portable application
environment. A user having a J2ME enabled mobile device will be able to
download applications from a network and run them on his/her mobile device.
Keywords: Java 2 Micro Edition (J2ME), PDA, Configuration, CDC, CLDC,
Profile, MIDP, JVM, KVM, JBED.

1
Table of Contents:
Table of Contents:............................................................................................2
Table of Figures: ..............................................................................................2
Introduction ......................................................................................................2
Configurations..................................................................................................4
CLDC: Connected Limited Device Configuration..........................................5
CDC: Connected Device Configuration ........................................................6
Profiles .............................................................................................................6
MIDP: Mobile information device profile (on top of CLDC) ...........................6
Foundation Profile (on top of CDC) ..............................................................7
Personal Profile (CDC, successor to PersonalJava) ....................................7
Other profiles................................................................................................7
Virtual Machines ..............................................................................................7
The K Virtual Machine (for the CLDC) ..........................................................7
JBED Micro Edition CLDC™ ........................................................................7
Other Virtual Machines .................................................................................8
Conclusions: ....................................................................................................8
Thanks: ............................................................................................................8
Abbreviations: ..................................................................................................8
References:......................................................................................................9
Listings.............................................................................................................9
Listing 1 ........................................................................................................9
Copyrights, trademarks, etc ...........................................................................11

Table of Figures:
Figure 1: Fragmentation of Java 2 ...................................................................3
Figure 2............................................................................................................5

Introduction
During the development of their new Java 2 platform Sun recognised in 1999
that they had to cut back from their motto “compile once, run everywhere”
(even though this wasn’t true beforehand and afterwards surely also not) and
decided to split up this new version of Java in three distinct parts:
• Java 2 Enterprise Edition (J2EE). For enterprises with a need to serve
their suppliers, customers and employees with Internet business server
solutions.
• Java 2 Standard Edition (J2SE). For the well-established desktop
market and Internet applications.

2
• Java 2 Micro Edition (J2ME). For consumer and embedded device
manufacturers who build many really divers kinds of information
devices, service providers who wish to deliver content to their
customers over those devices, and content creators for small,
resource-constrained devices.

Figure 1: Fragmentation of Java 2

Even so, the problem Sun had to face with the Micro Edition was that there
were entirely different run time environments among the target platforms.
Devices for J2ME could be:
• With / without keyboard.
• With / without display (grayscale / color).
• With / without network interface (LAN, WAN, Internet).
• Memory from some few 10kByte up to 16Mbyte.

The method of resolution chosen was the “device profile”, specifying a


minimum of Java classes for each class of devices. Like it’s bigger brothers,
Java 2 Micro Edition aims at maintaining the basic features that Java
technology boasts:
• Built-in consistency across products in terms of running anywhere, any
time, on any device.
• The power of a high-level object-oriented programming language with a
large developer base.
• Portability of code.
• Safe network delivery.

3
• Upward scalability with J2SE and J2EE.

At the higher level, J2ME is targeted at two distinct groups of products (see
FIGURE 1):
• Personal, mobile, connected information devices. E.g. Personal
organizers, Cell phones or pagers.
• Shared, fixed, connected information devices. E.g. Internet TVs, screen
phones, high-end communicators or car entertainment/navigation
systems.
As always is the case when distinguishing, the border between these two
product groups is fluid. To address the inherent diversity of the Java 2 Micro
Edition market, an essential requirement is not only small size but also
modularity and customizability. Because of this, the Java 2 Micro Edition
architecture was made modular and scalable to support this kind of flexible
deployment demanded by the target markets, which in this case are the
rapidly growing consumer and embedded markets.
For lower-end, resource-limited products (compared to normal personal
computers), Java 2 Micro Edition supports minimal configurations of the Java
virtual machine and Java APIs that provide and capture just the essential
capabilities of each kind of device. As device manufacturers add new features
to their devices, or service providers develop new and exciting applications,
these configurations will be expanded with additional APIs or with a richer
complement of Java virtual machine features. To support this kind of
customizability and extensibility, the two essential concepts of configurations
and profiles were defined.
New Configurations and profiles are created by an open process for defining
new additions to Java called “Java Community Process” (JCP).

Configurations
The J2ME platform covers a large range of different devices types. Devices
like TV set-top boxes, Internet TVs and high-end communicators have a large
range of user interface capabilities and memory budgets in range of 2 to 16
megabytes as well. On the other hand devices like simple mobile phones,
pagers and personal organizers have a very simple user interface and low-
level memory budget. Due to the large range of different type devices in the
J2ME market place, Sun has split the Java 2 Micro Edition in configurations.
Configurations define virtual machines features, Java language features and
Java API classes for each configuration environment. A J2ME configuration
defines a minimum platform for a “horizontal” class or family of devices, each
with similar requirements on total memory budget and processing power. A
configuration defines the Java language and virtual machine features and
minimum libraries that a J2ME supported device manufacturer or a content
provider can expect to be available on all devices of the same class.
To avoid fragmentation that could lead to confusion, Sun has introduced until
now only two configurations, which are:

4
CLDC: Connected Limited Device Configuration
• Very simple user interface (including no UI at all)
• Low level memory budgets (160 kB to 512 kB)
• 16 or 32 bit processors
• Wireless communication, possibly low bandwidth
• Limited power, often battery operation.
• Examples: Mobile phones, pagers and personal organizers.

CDC: Connected Device Configuration


• Large range of user interface capabilities (down to and including no UI)
• Memory budgets in range of 2 to 16 megabytes.
• 16 or 32 bit processors
• Connectivity to some type of network
• Examples: TV set-top boxes, Internet TVs and high-end
communicators

The relationship between CDC, CLDC and Java 2 Standard Edition is


illustrated in FIGURE 2. As shown there, the main functionality in CDC and
CLDC is inherited from the J2SE. All the classes which are inherited from the
J2SE are precisely the same or a subsets of the corresponding classes in the
J2SE and the classes which are outside the J2SE environment may not use
the java.* class names. Thus, upward compatibility is achieved between the
different editions of Java 2 platforms. All features implemented in the CLDC
are also implemented in the CDC to achieve upward compatibility between
J2ME configurations as well. Thus, all applications implemented for the
Connected Limited Device Configuration platform can be run in the
Connected Device Configuration platform as well.

Figure 2

CLDC: Connected Limited Device Configuration


The CLDC was the first configuration to be defined as it is bound to the main
target group: small toys or gadgets, which always are carried around by the

5
user, e.g. mobile phones or PDAs. So the market consisting of personal,
mobile, connected information devices is served by the CLDC. This
configuration includes some new classes, not drawn from the J2SE APIs,
designed specifically to fit the needs of small-footprint devices.
See also presentation 2 by Christoph Bürki & Tobor Dekany

CDC: Connected Device Configuration


The CDC serves the market consisting of shared, fixed, connected
information devices. To ensure upward compatibility between configurations,
the CDC is a superset of the CLDC (see FIGURE 2).
See also presentation 2 by Christoph Bürki & Tobor Dekany

Profiles
The configurations help already a lot to distinguish different types of devices.
But as there so many types around they still have to be refined further
because a configuration might cover devices intended for totally different
usage, like mobile phones and refrigerators, or washing machines and set-top
boxes. The mobile phone and e.g. a washing machine could belong to the
same configuration but it is obvious that a mobile phone application is not
expected to run on the washing machine or vice versa. Thus, the J2ME
framework provides the concept of a profile to achieve application
environment portability.
A J2ME profile addresses the specific demands of a certain “vertical” market
segment (e.g. banking or payment applications) or device category. Because
of this, profiles may include libraries that are far more device category specific
than the libraries provided in a configuration.
Profiles are implemented on top of a configuration. Applications then are
written for a specific profile, as profiles are assembled for a specific
configuration. Both profiles and configurations define a set of Java API
classes which can be used by the applications. A device that is designed to
support a profile or several profiles, agrees to implement all features and Java
API classes which are specified by the profile(s) and corresponding
configuration.
From an implementation viewpoint, a profile is just a collection of Java APIs
and class libraries residing on top of a configuration and providing domain-
specific capabilities for devices in a specific market segment.

MIDP: Mobile information device profile (on top of CLDC)


By building upon the CLDC, this profile will provide a standard platform for
small, resource-limited, wireless-connected mobile information devices like
cellular phones and two-way pagers. In addition to being wireless-connected,
these devices have small displays, limited input devices, limited local storage,

6
battery life, and CPU power. Two types of devices will be accommodated:
mobile information appliances and voice communication devices.
See also presentation 6 by Marco Dubacher & Markus Blatter.

Foundation Profile (on top of CDC)


The Foundation Profile serves two purposes. It provides a profile of the Java 2
Platform suitable for devices that need support for a rich network enabled
Java environment, but do not require a graphical user interface. Second, it will
provide a base profile for inclusion by other profiles that need to build on the
functionality it provides by adding graphical user interfaces or other
functionality.
See also presentation 7 by Simon Zürcher & Benjamin Tan.

Personal Profile (CDC, successor to PersonalJava)


See presentation 7 by Simon Zürcher & Benjamin Tan.

Other profiles
RMI profile (on top of Foundation Profile and CDC):
Provides interoperability with J2SE RMI.
PDA Profile (on top of CLDC)
See also presentation 6 by Marco Dubacher & Markus Blatter.

Virtual Machines

The K Virtual Machine (for the CLDC)


The KVM is a Java virtual machine that is developed for small, resource-
constrained devices such as mobile phones, pagers and personal organizers.
The KVM implements the CLDC. Because KVM is implemented in C it is
easily portable to different types of platforms. As the KVM comes from Sun it
is the standard / reference implementation for J2ME and is available for
Win32, Solaris, etc, on the other hand its performance isn’t very good
(compared e.g. with JBED).
See also Presentation 3 by Urs Waechli.

JBED Micro Edition CLDC™


JBED is a small and fast Java™ virtual machine (JVM) developed by the
Swiss company Esmertec that works on embedded devices like PDAs,
Internet Appliances and Smart Mobile Phones. Unlike most JVMs, JbedVM
CLDC™ always compiles bytecode to native (machine) code on the device
itself. Thus it is much faster than interpreted JVMs while still staying very

7
small. As the name implies JBED also implements the Connected Limited
Device Configuration

Other Virtual Machines


There are some other virtual machines for J2ME around (and more expected
around the corner) with various different features and specializations:
• Wabasoft: Waba- VM
• IBM: J9

Conclusions:
Sun provides a powerful yet easy to use (that is, if you know Java) toolkit /
framework with J2ME that could evolve to be the standard for the future for
embedded devices of all kinds. With the addition of more profiles in the future
this will be (or could be if they don’t overdo or underdo it) a well rounded
package which could easily be the standard for such things if everything goes
alright .
In my opinion, the success of J2ME will ultimately depend on its acceptance
and support by the device manufacturers (logical), the finding of a “killer
application” for devices not normally used as computers (e.g. washing
machines) and the quality of the different VMs for the different devices
(especially the code / bytecode reusability between different devices which is
nowadays not always given with J2SE). Another critical factor is the success
of the next generations of mobile phones, apart from Personal Digital
Assistants the biggest target platform existing at the moment. At the moment
this looks good, but with the dark cloud called UMTS (and spending too much
on licenses and stations for it) hanging in the sky over the telecommunications
industry this can change very fast (an added malus point is that there still
doesn’t seem to be a killer application for UMTS).

Thanks:
Krummi (he knows why)
Netcetera AG where I work (and did some of the research for this paper),
especially Joachim Hagger, Marco Torpo and Peter Brantschen (for his small
example)
Dr. R. Riedl

Abbreviations:
CDC Connected Device Configuration

8
CLDC Connected Limited Device Configuration
IBM International Business Machines, Inc.
J2EE Java 2 Enterprise Edition
J2ME Java 2 Micro Edition
J2SE Java 2 Standard Edition
JCP Java Community Process
JVM Java Virtual Machine
KVM K Virtual Machine
LAN Local Area Network
LAPD Los Angeles Police Department
MIDP Mobile Information Device Profile
PDA Personal Digital Assistant
UMTS Universal Mobile Telecommunication System
VM Virtual Machine
WAN Wide Area Network

References:
http://java.sun.com/
http://discolab.rutgers.edu/classes/cs672/j2me/Appendix1/CLDCappendix-
intro.pdf
http://www.hut.fi/~opaal/netsec/j2me.pdf
http://www.esmertec.com/
http://www.esmertec.com/p_jbed_cldc_long.html
http://www.cuj.com/java/articles/a9_fig.htm

Listings

Listing 1
/* @author Peter Meehan Copyright (c) 2000 */

import com.sun.kjava.*;

public class HelloWorld extends Spotlet {

/* Palm screen dimensions are constant */


private final int SCREEN_WIDTH = 160;
private final int SCREEN_HEIGHT = 160;

/* There is a single graphics context in the KVM */

9
Graphics g = Graphics.getGraphics();

Button button = null; // Lone UI button

/* When a key is pressed or a character is entered


via Graffiti or the soft keyboard, if it is the
Agenda hard key or the character 'q' quit. */
public void keyDown(int keycode) {
if ((keycode == Spotlet.KEY_HARD1) || (keycode == 'q'))
System.exit(0);
}

/* When the pen is tapped on the screen see if the button


* was pressed. If so quit */
public void penDown(int x, int y) {
/* test if pen in button and show button feedback */
if (button.pressed(x,y)) { System.exit(0); }
}

/* Display the hello world button to start */


public HelloWorld() {
String hello = "Hello World";
// get string dimensions
int stringWidth = g.getWidth(hello);
int stringHeight = g.getHeight(hello);
/* Create a centred button. */
button = new Button(hello,
(SCREEN_WIDTH-stringWidth)/2,
(SCREEN_HEIGHT-stringHeight)/2);
g.clearScreen(); // erase screen contents
button.paint(); // draw the button on the screen
}

/* Instantiate the spotlet instance and register


* for system key events */
public static void main(String args[]) {
Spotlet spotlet = new HelloWorld();
spotlet.register(Spotlet.WANT_SYSTEM_KEYS);

10
Copyrights, trademarks, etc
Jbed and Jbed Micro Edition CLDC are registered trademarks of esmertec,
Inc.
Sun, Sun Microsystems, the Sun logo, Java, Java 2 Platform Micro Edition,
J2ME, K Virtual Machine, KVM, Connected (Limited) Device Configuration,
Personal Java, JDK and some other terms are trademarks or registered
trademarks of Sun Microsystems, Inc. in the United States and other
countries.
Palm OS is a registered trademark of Palm, Inc. or its subsidiaries.
Some of the other product names used herein have been included for
identification purposes only and may be trademarks of their respective
companies.

The copyright for this document is by the University of Zürich and Urs Steiner.

11

You might also like