Advance Web/Internet Programming (Overview): J2ME

Comprehensive study notes, diagrams, and exam preparation for Advance Web/Internet Programming (Overview): J2ME.

Advance Web/Internet Programming: J2ME

Definition

J2ME (Java 2 Platform, Micro Edition) is a specialized subset of the Java platform designed specifically for resource-constrained devices, such as mobile phones, PDAs, and embedded systems. It provides a robust, secure, and flexible environment for developing applications that run on devices with limited memory, processing power, and display capabilities.


Main Content

1. Architecture of J2ME

  • Configurations: Defines the core Java Virtual Machine (JVM) features and minimum set of class libraries. Examples include CLDC (Connected Limited Device Configuration) for low-end devices and CDC (Connected Device Configuration) for more powerful devices.
  • Profiles: Built on top of configurations, profiles provide specific APIs for device types. The most common is the MIDP (Mobile Information Device Profile), which provides UI and networking capabilities.

2. The KVM (Kilo Virtual Machine)

  • Small Footprint: The KVM is a highly optimized, compact Java Virtual Machine designed to occupy as little memory as possible.
  • Resource Management: Unlike the standard JVM, the KVM strips away heavy features like complex garbage collection or large API libraries to ensure it can run on hardware with only a few kilobytes of RAM.

3. MIDlets

  • Application Structure: A MIDlet is the J2ME equivalent of an applet or application. It is a Java class that extends the javax.microedition.midlet.MIDlet class.
  • Lifecycle Management: MIDlets have a specific lifecycle controlled by the Application Management System (AMS), managing states like Paused, Active, and Destroyed.

Working / Process

1. Development Environment Setup

  • Developers use the Wireless Toolkit (WTK) or IDEs like NetBeans with specific J2ME plugins to simulate mobile devices on a desktop.
  • The process involves writing Java code that adheres to the limited library constraints of the target Profile.

2. Compilation and Pre-verification

  • Source code is compiled into standard Java bytecode.
  • A "pre-verification" step is performed by the preverify tool, which adds metadata to the bytecode to help the KVM run the application safely and efficiently.

3. Packaging and Deployment

  • The code and resources are bundled into a JAR (Java Archive) file.
  • A JAD (Java Application Descriptor) file is created, which contains information about the app's size, version, and requirements, allowing the device to verify compatibility before downloading.
[Source Code] --> [Compiler] --> [Bytecode] --> [Preverify] --> [JAR/JAD Package]
                                                                      |
                                                                [Target Device]

(Diagram: The lifecycle flow of a J2ME application from source to deployment)


Advantages / Applications

  • Platform Independence: "Write Once, Run Anywhere" (WORA) allows the same application to run on various mobile handsets regardless of the underlying OS.
  • Offline Capabilities: J2ME applications can store data locally using the Record Management System (RMS), allowing for functionality even without network connectivity.
  • Low Bandwidth Usage: Due to their small size, J2ME applications were historically favored for distribution over mobile networks with slow data speeds.

Summary

J2ME is a scaled-down Java platform optimized for embedded and mobile hardware, enabling developers to build portable applications using Configurations, Profiles, and MIDlets. It facilitates the creation of compact, secure, and efficient mobile software through a streamlined compilation and deployment process.

  • Important terms to remember: MIDlet, CLDC, MIDP, KVM, RMS, JAD/JAR.