Home > Store

Programming Wireless Devices with the Java  2 Platform, Micro Edition

Register your product to gain access to bonus material or receive a coupon.

Programming Wireless Devices with the Java 2 Platform, Micro Edition

Premium Website

  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 2001
  • Edition: 1st
  • Premium Website
  • ISBN-10: 0-201-74627-1
  • ISBN-13: 978-0-201-74627-3

This book presents the Java™ 2 Platform, Micro Edition (J2ME™) standards that support the development of applications for consumer devices such as cell phones, two-way pagers, and wireless personal organizers. To create these standards, Sun collaborated with such consumer device companies as Motorola, Nokia, NTT DoCoMo, Palm Computing, Research In Motion, Siemens and many others. The result is a highly portable, small-footprint application development environment that brings the unique capabilities of Java technology, including platform independence and enhanced security, to the rapidly growing wireless market.

This definitive Java™ Series guide provides a programmer's introduction to the Java 2 Platform, Micro Edition. It presents a general description of wireless technology, an overview of the J2ME platform, and information on the small-footprint K Virtual Machine. In addition, the book details the Connected Limited Device Configuration (CLDC) and the Mobile Information Device Profile (MIDP), the standards which define the Java platform features and libraries for wireless, resource-constrained devices.

Key topics include:

  • Overview of the Java 2 Platform, Micro Edition (J2ME)
  • Goals, requirements, and scope of the CLDC and MIDP standardization efforts
  • High-level CLDC and MIDP platform architecture, including the security model
  • CLDC application model, and compatibility with the Java programming language and virtual machine specifications
  • Class libraries supported by the CLDC standard
  • MIDP application model
  • MIDP libraries, including user interface, networking, and persistence APIs

Numerous sample applications illustrate how to put the technology and standards to work, including a PhotoAlbum application, an AddressBook application, and a Sokoban game application.

Written by a team of authors that includes the original J2ME technology experts from Sun and Motorola, this book provides both a description of the Java 2 Platform, Micro Edition, as well as practical implementation advice.



Source Code

Click below for Source Code related to this title:
Source Code

Sample Content

Downloadable Sample Chapter

Click below for Sample Chapter related to this title:

Table of Contents



1. Introduction.

The Wireless Internet Revolution.

Why Java Technology for Wireless Devices?

A Bit of History.

J2ME Standardization Efforts.

2. Overview of Java 2 Platform, Micro Edition (J2ME).

Java 2 Platform.

Java 2 Platform, Micro Edition (J2ME).

Key Concepts of the J2ME Architecture.

Introduction to the K Virtual Machine (KVM).

3. Goals, Requirements and Scope.

High-Level Goals.

Target Devices.

General Notes on Consumer Devices and Embedded Systems.


Scope of the CLDC and MIDP Standardization Efforts.

4. High-Level Architecture and Security.

High-Level Architecture.


5. Connected Limited Device Configuration.


CLDC Application Model.

Java Language Specification Compatibility.

Java Virtual Machine Specification Compatibility.

6. CLDC Libraries.

Background and Goals.

Classes Derived from J2SE60.

CLDC-Specific Classes.

7. Mobile Information Device Profile.

MIDP Expert Group.

Areas Covered by the MIDP Specification.

8. MIDP Application Model.

Limitations of the CLDC Application Model.


MIDlet Suites.@AHEADS = MIDP System Software.

9.IDP User Interface Libraries.

Structure of the MIDP User Interface API.

Abstract Commands.

Interactions with MIDlet Application Lifecycle.

Graphics and Canvas in the Low-Level API.

Low-level API for Events in Canvases.

Graphics Drawing Primitives.

Creating and Using Images.

Using Screens.

Using Items.

A Note on Concurrency.

10. MIDP Networking Libraries.

Characteristics of Wireless Data Networks.

Network Interface Considerations.

The HttpConnection Interface.

Sample Code (NetClientMIDlet.java).

11. MIDP Persistence Libraries.

The Record Management System.

Manipulating Record Stores and Records.

Sample Code (RMSMIDlet.java).

12. Additional MIDP APIs.

Timer Support.

System Properties.

Application Resource Files.

Exiting a MIDlet.

13. Sample Applications.

The PhotoAlbum Application.

The AddressBook Application.

The Sokoban Game Application.

Development Environments for J2ME.

14. Summary.

Appendix A. CLDC Application Programming Interface.






Appendix B. MIDP Application Programming Interface.







Index. 0201746271T04232001


In the past three and a half years, Sun has collaborated with major consumer device manufacturers and other companies to create a highly portable, secure, small-footprint Java application development environment for resource-constrained, wireless consumer devices such as cellular telephones, two-way pagers and personal organizers. This work started with the development of a new, small-footprint Java virtual machine called the K Virtual Machine (KVM). Two Java Community Process (JCP) standardization efforts, Connected, Limited Device Configuration (CLDC) and Mobile Information Device Profile (MIDP), were then carried out to standardize the Java libraries and the associated Java language and virtual machine features across a wide variety of consumer devices. Twenty four companies participated in these standardization efforts directly, and more than five hundred companies and individuals participated indirectly by sending feedback while the standardization efforts were in progress. Major consumer device companies such as Motorola, Nokia, NTT DoCoMo, Palm Computing, Research In Motion and Siemens played a key role in these efforts.

This book intends to make the results of the standardization work in the wireless Java technology area available to the wider software development community. At the high level, this book combines two Java Community Process Specifications, JSR-30 (CLDC 1.0) and JSR-37 (MIDP 1.0), and presents them as a single monograph. We have added a general introduction to the Java 2 Platform, Micro Edition (J2ME), provided more background material, and included a number of sample applications to illustrate the use of CLDC and MIDP in the real world. We also provide some guidelines and instructions for getting started with Java 2 Platform, Micro Edition.

A reference implementation of the software discussed in this book is available from Sun Microsystems under the Sun Community Source License (SCSL).

Intended Audience

This book is intended for software developers, content providers and other professionals who want to develop Java software for resource-constrained, connected devices. The book is also targeted to consumer device manufacturers who want to build small Java Powered devices and would like to integrate a compact Java application development platform in their products.

Objectives of This Book

This book intends to

  • provide an overview of Java 2 Platform, Micro Edition (J2ME),
  • provide a general introduction to the application development platforms defined by the J2ME standardization efforts,
  • explain the technical aspects of the J2ME Connected, Limited Device Configuration (CLDC),
  • explain the technical aspects of the J2ME Mobile Information Device Profile (MIDP),
  • provide sample programs to illustrate the use of CLDC and MIDP,
  • help you write your own J2ME applications.

How This Book Is Organized

The topics in this book are organized as follows:

  • Chapter 1, Introduction, provides a context for Java 2 Micro Edition and the CLDC and MIDP Specifications.
  • Chapter 2, Overview of Java 2 Platform, Micro Edition (J2ME), provides an overview of Java 2 Micro Edition, its configurations and profiles.
  • Chapter 3, Goals, Requirements and Scope, defines the high-level goals, requirements and scope of the CLDC and MIDP standardization efforts.
  • Chapter 4, High-Level Architecture and Security, presents the high-level architecture of the CLDC and MIDP standards, as well as discusses the security features of these standards.
  • Chapter 5, Connected Limited Device Configuration, introduces the CLDC standardization effort and summarizes the supported Java programming language and virtual machine features compared to the Java 2 Platform, Standard Edition.
  • Chapter 6, CLDC Libraries, introduces the Java class libraries defined by the CLDC Specification.
  • Chapter 7, Mobile Information Device Profile, introduces the MIDP standardization effort.
  • Chapter 8, MIDP Application Model, introduces the MIDlet application model defined by the MIDP Specification.
  • Chapter 9, MIDP User Interface Libraries, introduces the user interface libraries defined by the MIDP Specification.
  • Chapter 10, MIDP Networking Libraries, introduces the networking libraries defined by the MIDP Specification.
  • Chapter 11, MIDP Persistence Libraries, introduces the record management system (RMS) defined by the MIDP Specification.
  • Chapter 12, Additional MIDP APIs, introduces some additional MIDP application programming interfaces (APIs) such as Timers.
  • Chapter 13, Sample Applications, illustrates the use of CLDC and MIDP libraries through some sample applications.
  • Chapter 14, Summary, provides a summary of the topics discussed in the book, as well as outlines some future directions.

Related Literature and Helpful Web Pages

The Java Language Specification by James Gosling, Bill Joy, and Guy L. Steele. Addison-Wesley, 1996, ISBN 0-201-63451-1
The Java Language Specification, Second Edition by James Gosling, Bill Joy, Guy L. Steele, and Gilad Bracha. Addison-Wesley, 2000, ISBN 0-201-31008-2
The Java Virtual Machine Specification, Second Edition by Tim Lindholm and Frank Yellin. Addison-Wesley, 1999, ISBN 0-201-43294-3
Connected, Limited Device Configuration Specification,
Mobile Information Device Profile Specification,
Java 2 Micro Edition Product Web Page
K Virtual Machine (KVM) Product Web Page
Connected, Limited Device Configuration (CLDC) Product Web Page
Mobile Information Device Profile (MIDP) Product Web Page
J2ME Wireless Toolkit Product Web Page


Like most books, this book represents the work of many people. In this case, however, an unusually large number of people around the world have worked to make the Java 2 Platform, Micro Edition--and hence this book--a reality. What started out as a two-person research project at Sun Labs grew rapidly into a highly collaborative product development and standardization effort involving hundreds of people in different companies. It is impossible to name all the people who participated and contributed to this work without inevitably forgetting many key names. The summary below is an attempt to give a high-level glimpse into the different groups of people who participated in this journey. To these and many others too numerous to mention, we give our thanks and appreciation for what they did to make these ideas and this book possible.

Many people read draft versions of this book, making comments that improved it substantially. The authors would like to thank David Baum, Bill Bush, Cristina Cifuentes, Greg Czajkowski, Steffen Grarup, Dean Hall, Laura Hill, Karen Hsiang, Tim Lindholm, Stuart Marks, Tasneem Sayeed, Howard Thamm, Ravi Viswanathan and Frank Yellin for their willingness to send comments and constructive criticism on the various versions of the book and the sample MIDlets. As usual, any remaining errors are the sole responsibility of the authors. Special thanks to Mark Patel for contributing the animation code in Chapter 9.

The authors would also like to thank Lisa Friendly for allowing us to publish this book in Sun's Java book series and for lending us capable technical writing resources to finish this book. Jim Holliday, our technical writer and editor at Sun Microsystems, edited various versions of this book tirelessly. Without his expertise in the mysteries of desktop publishing, grammar and that pesky topic known as punctuation, this work would have been much worse for the wear.

Numerous companies have been involved in the standardization efforts related to the Java 2 Platform, Micro Edition. The following companies participated in the CLDC and MIDP standardization efforts discussed in this book: America Online, Bull, DDI, Ericsson, Espial Group, Fujitsu, Hitachi, J-Phone, Matsushita, Mitsubishi, Motorola, NEC, Nokia, NTT DoCoMo, Oracle, Palm Computing, Research In Motion (RIM), Samsung, Sharp, Siemens, Sony, Sun Microsystems, Symbian and Telcordia Technologies. We would like to thank all the CLDC and MIDP expert group members and other individuals from the aforementioned companies for their active participation and contributions.

In addition to the companies listed above, hundreds of other companies and individuals sent us feedback while the CLDC and MIDP standardization efforts were in progress. The authors found it amazing how much of their time people were willing to contribute to ensure the progress of the Java technology in the wireless space.

From Sun, we would like to thank Bert Sutherland and Neil Wilhelm at Sun Labs for their initial support and encouragement to start the Spotless research project that led to the development of the K Virtual Machine (KVM) and the subsequent product development efforts. Bill Bush, Doug Simon and Bill Pittore played an essential role in the development of the Spotless system--the precursor of the KVM. Thanks to the continued efforts and support by Jon Kannegaard, Jim Mitchell, Bob Sproull, Mario Wolczko and many other people at Sun Labs, the active exchange of ideas and technology--and sometimes people--has continued even after the Spotless system had been successfully transferred into a product organization.

Like Bert Sutherland constantly used to remind people when he was the director of Sun Labs, technology transfer is a contact sport. Alan Brenner, Bill Bush, Mitch Butler, Mike Clary, Jim Mitchell, Moshe Gotesman, Frank Yellin and many others had a central role in ensuring the successful transfer of the Spotless technology to the Java Software product organization. Alan Brenner, who subsequently became the director of the Java Consumer Software organization, nurtured the initial product teams and visited numerous companies to gain support for the proposed standardization efforts in this area.

Various product groups in Sun's Java Software division participated in the design and implementation of the CLDC and MIDP reference implementations. The authors would like to thank the KVM team, MIDP team and Wireless Toolkit team members who worked on the reference implementations of the standards and products discussed in this book. The TCK (Technology Compatibility Kit) and Quality Assurance teams at Java Consumer Software also played a critical role in ensuring the quality and compatibility of the products. Special thanks go to Karen Hsiang for keeping all the teams coordinated, as well as to Alex Kuzmin for his relentless pursuit of quality and his willingness to go that extra mile (and spend those extra hours!) to make things happen on time.

From Motorola, we would like to thank Jim Van Peursem for co-representing Motorola in the MIDP expert group. Every project has its genesis, and the KVM project within Motorola had its start with the team of Bala Kumar, Matt Long, Jim Lynch, John Osman, Iris Plaxton, Paul Su and Ranjani Vaidyanathan--thanks guys for being there from the beginning and making CLDC and MIDP happen in Motorola.

Someone once said that hardware without software is a space heater. Similarly, without products, the CLDC and MIDP specifications are limited in their value. Thanks to Jyh-han Lin's Florida-based iDEN team for taking the earlier KVM efforts seriously, putting KVM in their product roadmaps, and shipping Motorola's first CLDC and MIDP compliant phone. In a similar vein, thanks to Michael Chu's Beijing-based "Tai Chi" team for their support. Finally, a big thanks to the Austin-based Wireless Software and Services (WSAS) team under Anne-Marie Larkin, in particular to Scott Osborne who managed the CLDC and MIDP engineering team, and to Jim Erwin who managed the CLDC and MIDP test team.

The preparation of this book has been a rather challenging endeavor itself. All the authors are located in different states and time zones, and because of the extensive amount of travel involved in standardization and product development work these days, a significant portion of the text in this book was written in airplanes, airports and hotels. Luckily, the advances in wireless technology have made it easier for people to stay in touch regardless of their physical location. Unfortunately, it also means that it is increasingly difficult to avoid those after 8 pm phone calls and urgent text messages and e-mails, especially from your co-authors and colleagues located in more Western time zones. The standards defined in this book, for better or worse, will probably only accelerate this trend.

And finally, but most importantly, Roger would like to thank Cathy, Kimberly, Brian and Catie for their support and forbearance during this exciting and intensive endeavor.

Antero would like to thank Leena, Eva Maria, Eetu and Ella for their love and support.

Mark would like to thank Joy, Zachary and Abby for their love, support, patience and understanding about those long trips and time away from home.

Roger Riggs, Burlington, Massachusetts
Antero Taivalsaari, Cupertino, California
Mark VandenBrink, Austin, Texas
April 2001



Abstract Windowing Toolkit, 101
AddressBook example, 211
Alert, 128, 317
AlertType, 317
anchor points, 117
animation, 119
API documentation
CLDC, 271
MIDP, 309
descriptor, 95
development environment, 19
AddressBook, 211
PhotoAlbum, 188
Sokoban Game, 237
Java, 45
management, 46, 98
operations, 99
installation, 99
launching, 99
removal, 99
retrieval, 99
version management, 99
management software, 98
MIDlet lifecycle, 106
CLDC, 44
limitations, 83
example, 188
MIDP, 83
resource files, 184
resource files, specific, 56
See example.
drawing and filling, 115
ArithmeticException, 277
ArrayIndexOutOfBounds, 277
ArrayStoreException, 277
AWT, 101
Boolean, 278
Byte, 278
byte arrays
converting record data to and from, 161
ByteArrayInputStream, 291
ByteArrayOutputStream, 291
Calendar, 62, 299
Canvas, 107, 318
See also canvas.
coordinate system, 109
action, 112
key, 112
pointer, 113
redrawing mechanism, 108
scaling to, 113
visibility, 112
CDC, 15
Character, 278
character encoding, 64
Choice interface, 319
ChoiceGroup, 132, 320
Class, 279
Alert, 317


Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership