|
The Java 2 Platform, Micro Edition (J2ME) is aimed at the market for consumer and embedded electronic devices: cellular telephones, two-way pagers, Personal Digital Assistants (PDAs), set-top boxes, and other small devices. Since J2ME's release, hundreds of companies have joined the development effort, including large corporations such as Motorola, Nokia, Ericsson, Palm, Samsung, WindRiver, Sharp, Siemens, Sympian, and RIM. This vote of confidence is not surprising; J2ME provides a complete set of solutions for creating state-of-the-art networked applications for small devices. An added attraction is that the direction J2ME travels is not masked in corporate secrecy; its development is handled openly, through the Java Community Process (JCP). Currently, J2ME offers two standard configurations: The Connected Limited Device Configuration (CLDC) is prevalent in the J2ME world, and powers cellular phones, pagers, PDAs, and other handheld devices. The Connected Device Configuration (CDC) targets more powerful devices, such as home appliances, set-top boxes, and Internet TVs. The Mobile Information Device Profile (MIDP) runs on top of the CLDC, and several profiles run on top of CDC. This article is a tutorial introduction to CDC, its virtual machine CVM, and three related profiles: Foundation, Personal, and Personal Basis. This article:
A High-Level View of J2ME J2ME defines two major categories of components:
These components make up the J2ME architecture, as shown in Figure 1. At the heart of J2ME is a configuration, whose Java virtual machine interacts with the device's host operating system. One or more J2ME profiles add programming libraries that provide access to device capabilities such as I/O and GUI. Together, a configuration and a profile compose a J2ME runtime environment. For example, the MIDP profile sits on top of the CLDC configuration, which includes the KVM virtual machine. A number of optional packages extend the J2ME platform, offering standard APIs for using existing and emerging technologies (Bluetooth and web services, for example). Optional packages provide access to services that are useful on more than one class of device, but not on all.
Figure 2 shows how CDC and its related technologies realize this architecture.
CDC CDC is a Java Community Process effort (JSR 36) that has standardized a portable, Java-technology building block for consumer electronics and embedded devices. It provides a set of basic libraries and a Java virtual machine appropriate for use with profiles for vertical product markets. CDC targets powerful devices that are intermittently connected to a network, including set-top boxes, interactive TVs (iTVs), home appliances, and car navigation systems. CDC contains a full-featured Java virtual machine. CVM's capabilities are similar to the JVMs that support the Java 2 Platform, Standard Edition (J2SE). The main differences lie in the memory and display capabilities of the devices targeted. A device that meets the resource requirements that J2ME specifies for CDC:
It's worth noting that applications written using the CLDC APIs are upward-compatible with CDC. The CDC Class Library CDC includes a minimal set of APIs, only those packages from J2SE v1.3 needed to build and run a virtual machine:
CVM The CDC configuration defines its own subset of JVM features. Its virtual machine is called CVM.
CVM is designed for the consumer and embedded devices that CDC targets. The reference implementation currently available from Sun Microsystems runs on Linux and VxWorks. It is implemented almost entirely in C, with about 100 lines of assembly code, and contains a well-documented porting layer that leaves anyone targeting a new platform a bare minimum of work to do.
Profiles for CDC To make it possible to define Java platforms for vertical product markets, J2ME introduces profiles. At the implementation level, a profile is a set of APIs that reside on top of a configuration and give applications access to the capabilities of a category of devices. The profiles defined on top of CDC are the Foundation Profile, the Personal Profile, and the Personal Basis Profile. The Foundation Profile As its name suggests, the Foundation Profile is meant to serve as a foundation for other profiles, such as Personal and Personal Basis. It extends the APIs provided by CDC to provide those services that virtually all CDC-based applications need. Because not all need a user interface, this profile doesn't provide any UI APIs.
The foundation profile contains all the basic packages in J2SE 1.3 except the ones needed to support the GUI classes of
The Personal Profile To support web-based applets, the Personal Profile extends the Foundation Profile with packages that provide a graphical user interface (GUI). The Personal Profile is a redefinition of PersonalJava, and therefore is backward-compatible with PersonalJava 1.1 and 1.2 applications. In other words, it provides the functionality of the PersonalJava environment in a next-generation J2ME profile. What is interesting about the Personal Profile is that it can support many graphics library specifications, such as Home Audio-Video interoperability (HAVi) and the Java TV API. Applications based on the Personal Profile can be graphical or non-graphical. The profile provides graphics APIs based on the Abstract Windowing Toolkit, including the AWT's lightweight and heavyweight components. Applications with modest GUI requirements can use the Personal Basis Profile, which provides basic AWT support but excludes the heavyweight components. The Personal Profile is a superset of the Personal Basis Profile, and applications based on the latter are upward-compatible. For example, an Xlet written for the Personal Basis profile will run on the Personal profile.
You can use the Personal profile to create a wide variety of applications for PDAs, telematics, iTV, lottery terminals, and medical devices, electronic program guides for television, stock tickers, and home server applications for controlling home appliances and household services such as heating, lighting, entertainment, and security. Some of the features of the Personal profile are:
Application Models The Personal Profile supports three kinds of applications:
Applets are well suited for use with Internet browsers. Xlets on the other hand are suited for consumer-device applications such as television broadcasting, and indeed the Xlet application model was originally designed for iTV applications. Applets usually have a GUI, but don't always need one. An application that doesn't require a GUI can run as an Xlet. Such applications display some graphics on the screen and provide some interaction with the user. They synchronize with audio and video devices, and have a limited life. The Personal Basis Profile
The Personal Basis Profile is a subset of the Personal Profile, and applications written for it are upward-compatible. This profile supports Xlets as well as typical applications containing The Personal Basis Profile is well suited to the interactive TV market, as it contains the APIs necessary for the Java platform to support the Multimedia Home Platform (MHP) currently being developed. The MHP is a standard for enhanced broadcast interactive services; it defines an interface between interactive applications and the devices on which they run. For more information on MHP, see Digital Video Broadcasting Multimedia Home Platform. The Personal Basis profile is also compatible with other major specifications for consumer electronics, such as Home Audio-Video interoperability (HAVi), the OpenCable Application Profile middleware specification for iTV services and MHP-based applications, and the DTV Applications Software Environment (DASE), an enhanced television standard that defines middleware that allows interactive and enhanced applications to run on a common receiver. Downloading and Building CDC/CVM/Foundation As I mentioned earlier, the J2ME CDC technology is available for the Linux operating system. If you have access to Linux, you can start developing future-generation applications for consumer electronic devices. The remainder of this article leads you through the processes of downloading and installing the resources you'll need, and of building applications. You can download CDC, the Foundation Profile, and all the other profiles from the Sun Download Center if you're a member of the Java Developer Community (JDC membership is free). The configuration and the profiles come in source format, so you'll need to compile the code yourself. To do so, you will need to fulfill the following requirements:
If you have a machine that satisfies these requirements, download CDC and the Foundation Profile, and unzip the archive file containing the source. Note that you can build CDC by itself or with the Foundation Profile. If you build the profile, you'll be building both, because the Foundation Profile contains all the CDC libraries. You may wish to skip the first procedure, and begin at "To build the Foundation Profile with CDC." To build CDC:
The
If all goes well, several files will appear in the
To test your installation, change directory to
This command runs CVM to execute the class To build the Foundation Profile with CDC:
The
Again, the
If all goes well, several files will appear in the
To test your installation, change directory to:
This command runs CVM to execute the class Developing and Compiling New Applications You can develop applications for the Foundation Profile the same way you develop J2SE applications. Remember, however, that this profile doesn't include any GUI libraries, so all applications for the Foundation profile are command-line programs. Here is a typical Hello application:
Save this code in a file
This command will produce
Building and Installing the Personal Profile
Sun Microsystems has made a compiled version of the Personal Profile Runtime Environment
available so you can avoid the hassle of compiling the source code to build the implementation. If you download and unpack the binary distribution, you will get a new directory If you prefer to build and install the Personal Profile yourself, download its reference implementation to your Linux machine from the Sun Download Center, and unzip the source archive file. Then:
If all goes well, the
To test your installation, change directory to:
This command executes Here is a sample Hello applet:
To test this applet, copy it to a file
Before you can run it, you first need to create an HTML file
Now you can run the applet:
Installing the Personal Basis Profile To install the Personal Basis profile, download its reference implementation to your Linux machine, and unzip the archive. To build the implementation:
If all goes well, this command will produce several files in
To test your installation, change to
This command executes You should also test the installation with an Xlet. To compile the Xlet using the Personal Basis profile APIs, use:
To run it, enter:
Conclusion This tutorial introduced CDC and its associated profiles. The article described the architecture of CDC and the application models of the related profiles. It also provided detailed instructions on downloading, building, and installing CDC and its profiles, and furnished sample applications, along with instructions for compiling and running them. The CDC technology is very interesting. I particularly like the Personal Basis profile's upward compatibility with various major standard specifications for home appliances. Sun Microsystems has made available some optional packages for CDC such as those that provide support RMI and JDBC. For more information
- CDC (JSR 36) Acknowledgments Special thanks to Mark Fulks and Dan Stevens of Sun Microsystems whose feedback helped me improve the article. Back To Top | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||