Java 2 Micro Edition (J2ME) is built around a modular architecture consisting of profiles, configurations, virtual machines, and host operating systems, which together provide a complete J2ME runtime environment. Figure A shows how these pieces fit together. J2ME offers two configurations—the Connected Limited Device Configuration (CLDC) and the Connected Device Configuration (CDC). These two configurations target different types of devices based on the devices' available memory footprint for Java.
A configuration specifies the minimum set of features and Java class libraries that the associated Java virtual machine (JVM) should support. Conceptually, the configuration layer runs on top of the virtual machine (VM). But when you use a configuration such as the CLDC or CDC, you are talking about the associated VM as well, because the two are closely linked.
It should be noted, however, that in J2ME design, a configuration like CLDC is not tightly bound to a particular VM and can work with other VMs supporting the necessary libraries. For example, CLDC can also work with other VMs that implement the basic features it specifies. For details, see the CLDC HotSpot implementation virtual machine white paper.
To help you understand the role of the J2ME configuration layer, I'll examine the CLDC and CDC separately.
CLDC: For the lower-end devices
CLDC is the J2ME configuration for devices with less than 512 KB memory footprint available for Java environment and applications. CLDC is for the kilo VM (KVM), which is a highly optimized JVM meant for lower-end, network-connected, battery-operated devices based on 16-bit or 32-bit microprocessors with around 160 to 512 KB memory for Java. Typical memory requirement is around 128 KB for storage of KVM and the associated libraries. More information on the KVM can be obtained from Sun's KVM white paper.
As far as networking is concerned, CLDC targets devices with limited and intermittent wireless connectivity. All applications that run on J2ME CLDC should run on any other higher-end Java VM, provided, of course, that the CLDC libraries are available. CLDC configuration addresses areas related to the I/O, networking, security, internationalization, and core Java libraries.
Areas related to event handling, user-application interaction, and application lifetime management are handled by profiles. User interface definitions (which are specific to particular device categories, like pagers, mobile phones, and PDAs) are also under the scope of the profile layer, which is built on top of and which utilizes the J2ME configurations. Mobile Information Device Profile (MIDP) is the J2ME profile that, among other things, defines the user interface-related specifications for devices using CLDC configuration.
CLDC draws most of the classes from J2SE. But some new classes specific to small memory footprint devices are not drawn from J2SE APIs. For specific information about the classes inherited from J2SE and new CLDC classes, refer to section 6.2 and 6.3 of CLDC specification version 1.0a. Some of the notable exceptions from the Java language specifications include no floating-point support, no support for finalization of class instances, and limited error-handling capabilities.
It's relevant here to mention the CLDC HotSpot implementation from Sun, which serves as a Java VM alternative to KVM for devices using a CLDC configuration. According to Sun, the CLDC HotSpot implementation VM is a high-performance JVM (32 bit, complying with CLDC specification v1.0) that offers nearly an order of magnitude better performance than the KVM while running on almost the same small memory footprint.
CDC: The full Java platform
CDC is the J2ME configuration for devices with relatively larger memory, typically 2 MB or more. CDC targets devices with limited and intermittent wireless connectivity. CDC, together with CVM (C Virtual Machine) and the Foundation profile (currently the only profile for CDC), defines the complete J2ME environment.
CVM is a fully functional JVM designed for consumer and embedded devices. It supports all Java 2 v1.3 VM security, JNI, JVMDI, RMI, and weak references features and libraries. Essentially, a CVM has all the functionality of a JVM residing on a desktop system.
CDC consists of minimal Java packages from J2SE. The Foundation profile consists of the remaining class libraries and APIs required for consumer devices. Both CDC and the profile use J2SE-based APIs, removing all the deprecated APIs. Therefore, if you're working in a CDC-based J2ME environment, you'll need to update your code (if initially written for J2SE environment) to replace the deprecated APIs with the new equivalents.
CDC is a superset of CLDC. so there's upward compatibility between the two configurations. CDC and the Foundation profile also provide full compatibility to applications developed using the PersonalJava runtime specification.
More on CLDC and CDC
- Information on CLDC
- J2ME CLDC reference implementation
- Official CDC specification (JSR #36)
- Information on CDC
Wrapping it up
J2ME modular architecture enables creation of “special editions” Java for different device categories. As more and more device manufacturers start adopting J2ME technology, and the range of devices using J2ME increases, newer J2ME profiles will need to be implemented. By providing a common minimum platform for development of Java-based services, J2ME configurations enable creation of these special editions in a structured way.