The Basics of J2ME
By John W. Muchow
This is a sample chapter from Core J2ME Technology and MIDP.
Topics in this Chapter
- Java Editions
- Why J2ME?
- Java Virtual Machines
- Big Picture View of the Architecture
- Compatibility between Java Editions
- Putting all the Pieces Together
It all started with one version of Java—now known as Java 2 Standard Edition (J2SE)—and the tagline "Write Once, Run Anywhere TM." The idea was to develop a language in which you would write your code once, and then it would run on any platform supporting a Java Virtual Machine. Since its launch in 1995, the landscape has changed significantly. Java has extended its reach far beyond desktop machines. Two years after the introduction of Java, a new edition was released, Java 2 Enterprise Edition, providing support for large-scale, enterprise-wide applications. The most recent addition to the family is the Micro Edition, targeting "information appliances," ranging from Internet-enabled TV set-top boxes to cellular phones.
Let's begin with a quick summary of the Java platforms currently available:
- Standard Edition (J2SE): Designed to run on desktop and workstations computers.
- Enterprise Edition (J2EE): With built-in support for Servlets, JSP, and XML, this edition is aimed at server-based applications.
- Micro Edition (J2ME): Designed for devices with limited memory, display and processing power.
Note: In December of 1998, Sun introduced the name "Java 2" (J2) to coincide with the release of Java 1.2.This new naming convention applies to all editions of Java, Standard Edition (J2SE), Enterprise Edition (J2EE), and Micro Edition (J2ME).
Figure 1-1 shows various Java editions.
Figure 1-1 The various Java editions
J2ME is aimed squarely at consumer devices with limited horsepower. Many such devices (e.g., a mobile phone or pager) have no option to download and install software beyond what was configured during the manufacturing process. With the introduction of J2ME, "micro" devices no longer need to be "static" in nature. Not unlike a web browser downloading Java applets, an implementation of J2ME on a device affords the option to browse, download and install Java applications and content.
Small consumer electronics have a way of changing our lives. Mobile phones let us communicate when away from our home or office. Personal digital assistants (PDAs) let us access email, browse the internet and run applications of all shapes and forms. With the introduction of Java for such devices, we now have access to the features inherent to the Java language and platform. That is, a programming language that is easy to master, a runtime environment that provides a secure and portable platform and access to dynamic content, not to mention an estimated developer community of over 2 million people.Although it would be nice to have the entire J2SE Application Programming Interface (API) available on a micro device, it's not realistic. For example, a mobile phone with its limited display cannot provide all the functionality available in the Abstract Window Toolkit, the first graphical user interface released with Java. The "Micro Edition" was introduced to address the special needs of consumer devices that are outside the scope of J2SE and J2EE.
The capabilities of devices within the "Micro Edition" may vary greatly. An Internet Screenphone (a hardware device designed to provide access to email, news, online banking, etc.) may have a much larger display than a pager. However, even devices that seem similar in size may vary greatly in their capabilities. A cell phone and PDA are both limited in physical size, yet a typical cell phone may have a display with a total resolution of 12,288 pixels (96 x 128), whereas a PDA resolution may start at 20,000 pixels and go up from there.
One Java platform will most definitely not fit all. To better understand how J2ME will accommodate a broad range of consumer electronics and embedded devices, we need to introduce two new concepts, configurations and profiles.