Preface

This book is a desktop quick reference for the Java™ 2 Micro Edition (J2ME™). It is intended for Java programmers writing applications for devices with limited memory resources and processor power, such as cell phones, Personal Data Assistants (PDAs), and set-top boxes. The first part of this book provides a fast-paced introduction to the two different configurations that make up the J2ME platform -- the Connected Limited Device Configuration (CLDC) and the Connected Device Configuration (CDC), along with the profiles that are based on them, such as the Mobile Information Device Profile (MIDP), which provides the APIs for programming cell phones and similar devices. These chapters are followed by a quick-reference section that details each class of the CLDC and MIDP APIs, along with tables that show which Java packages and classes are available in each configuration and profile.

This book is intended to be used in conjunction with the best-selling Java in a Nutshell, by David Flanagan, and Java Enterprise in a Nutshell, by Jim Farley, David Flanagan, and William Crawford (both published by O’Reilly). Java in a Nutshell introduces the Java programming language itself and provides an API quick reference for the core packages and classes of the Java 2 Standard Edition (J2SE) platform. Java Enterprise in a Nutshell does the same for the APIs in the Java 2 Enterprise Edition (J2EE). The CDC and its profiles are actually large subsets of the J2SE API, and, therefore, this book does not replicate their API quick reference material, which you can find in Java in a Nutshell and, in the case of the RMI profile, in Java Enterprise in a Nutshell.

Contents of This Book

The first nine chapters of this book describe the J2ME platform, the command-line tools that are provided with Sun’s J2ME reference implementations, and some of the visual development environments that you can use when writing J2ME applications:

Chapter 1

This chapter introduces the J2ME platform and the concepts of configuration and profile, and it compares J2ME to a number of other Java platforms for small devices.

Chapter 2

This chapter covers the Connected Limited Device Configuration (CLDC), which is the basic building block for the J2ME profiles for wireless devices and PDAs. It begins by outlining the differences between CLDC and the core libraries of the J2SE platform. Then it takes a close look at KVM, the small-footprint virtual machine that is used in Sun’s reference implementation of CLDC.

Chapter 3

This chapter introduces MIDlets, the wireless Java equivalent of applets. MIDlets are part of the Mobile Information Device Profile (MIDP), which is the subject of this and the following three chapters. This chapter looks at the lifecycle of a MIDlet and illustrates it with a simple example. It concludes with a discussion of the facilities that a typical mobile device would provide to allow the user to download, install, manage, and remove MIDlets.

Chapter 4

The devices that MIDlets run on range from cell phones with a small two-color display and room for only a few lines of text to PDAs with larger, multicolor screens. In order to isolate MIDlets from the specifics of the devices on which they are running, MIDP includes a high-level API that provides simple input and output controls and the ability to combine these controls to create form-like screens. This chapter takes a detailed look at the high-level API and provides sample MIDlets that can be run on cell phones or PDAs.

Chapter 5

This chapter looks at an alternative user interface API that provides lower-level access to a mobile device’s screen and input devices. This chapter looks at the details of this API and shows how to avoid writing code that may not be portable between devices with different user interface capabilities.

Chapter 6

Networking is a key feature of a mobile device. The first part of this chapter looks at the Generic Connection Framework (GCF), which provides the basis for access to various networking APIs, including optional protocols (such as sockets and datagrams) and HTTP, which all MIDP implementations are required to support. A simple example that involves fetching information from a web site is used to illustrate the use of HTTP on a mobile device and shows how to avoid problems that arise when working in an environment with limited memory. The second part of this chapter looks at the facilities available for storing information on a mobile device and illustrates them by extending the HTTP example to include persistence of information retrieved from the web site.

Chapter 7

This chapter looks at the Connected Device Configuration (CDC) and its profiles, which are designed for use on devices that have more than 2 MB of memory to devote to the Java platform. It begins by looking at Sun’s reference implementation of CDC and the CVM, the virtual machine for CDC devices, then briefly covers the content of the CDC-based profiles that are currently defined.

Chapter 8

This chapter contains reference material for the command-line tools that are provided with the CLDC and CDC reference implementations and the MIDP for the PalmOS product.

Chapter 9

This chapter covers the J2ME wireless toolkit, a development environment provided by Sun that allows you to create and test MIDlets using a cell-phone emulator that can be customized to resemble a number of different cell phones and PalmOS-based handhelds. It also looks at how to use the wireless toolkit in conjunction with Sun’s Forte for Java IDE to create a complete development environment, and it investigates a number of alternative third-party products that provide similar functionality.

These first nine chapters provide a tutorial introduction to J2ME, with particular emphasis on wireless devices, which are currently the most popular application of J2ME technology. The core of this book, however, is the API quick reference, Chapter 10 through Glossary, which is a succinct but detailed API reference formatted for optimum ease of use. Please be sure to read “How To Use This Quick Reference,” which appears at the beginning of the reference section; it explains how to get the most out of this section.

Get J2ME in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.