You are on page 1of 5

J2ME Application life cycle and difference Between J2SE and J2ME

1) Introduction
J2ME (Java 2 Micro Edition) is an advanced technology in Java, developed with the help of Java Community Process Program. J2ME is a reduced version of the Java API and Java Virtual Machine that is designed to operate within the limited resources available in the embedded computers and microcomputers. J2ME is targeted to developers of intelligent wireless devices and small computing devices who need to incorporate cross-platform functionality in their products. A key benefit of using J2ME is compatibility with all Java-enabled devices. Motorola, Nokia, Panasonic all have Java-enabled devices.A J2ME application is a balance between local and server-side processing. The Java Community Process Program used a two approaches to addressing the needs of small computing devices. Page 1 - Introduction to J2ME Page 2 - Simple Example Program Discuss Here Configurations: It is the Java run-time environment and core classes that operate on each device. A configuration defines the Java Virtual Machine for a particular small computing device. There are two configurations. o CLDC for handheld devices:The CLDC (Connected Limited Device Configuration) is designed for 16-bit or 32-bit small computing devices with limited memory. These devices usually have between 160KB and 512KB of available memory. Usually these are powered by battery. They use small-bandwidth network wireless connection. These devices uses a strippeddown version of the JVM the KJava Virtual Machine (KVM). These devices include pagers, personal digital assistants, cell phones, dedicated terminals, and handheld consumer device. o CDC for plug-in devices:CDC(Connected Device Configuration) devices use a 32-bit architecture, have at least 2 MB of memory available, and implement a complete functional JVM. CDC devices include digital set-top boxes, home appliances, navigation systems, point-of-sale terminals, and smart phones. Profiles: It is defined for categories of small computing devices. A profile consists of classes that enable developers to implement features found on a related group of small computing devices.List of J2ME Profiles: o Profiles Used with CLDC: Mobile Information Device Profile(MIDP) PDA Profile(PDAP) o Profiles Used with CDC: Foundation Profile Game Profile Personal Profile Personal Basis Profile RMI Profile.

J2ME Application life cycle and difference Between J2SE and J2ME
2)J2ME Architecture
There are 5 layers in J2ME Architecture.Those are: MIDP (TopMost Layer): Which contains Java APIs for user network connections, persistence storage, and the user interface. It also has access to CLDC libraries and MIDP libraries. J2ME APIs(Profiles): Which consists of the minimum set of application programming interfaces for the small computing device Configurations: Which handles interactions between the profile and the JVM. JVM Operating System(Bottom Layer).

1,2 and 3 are software Layers.

3) Midlets.
A MIDlet is a J2ME application which operate on an MIDP. A MIDlet is defined with at least a single class that is derived from the javax.microedition.midlet.MIDlet abstract class. Common programming is grouping related MIDlets into a MIDlet suite, which is contained within the same package and implemented simultaneously. All MIDlets within a MIDlet suite are considered a group and must be installed and uninstalled as a group. MIDlets from the same MIDlet suite run the same class. Benefit of the relationship among MIDlet suite members is that they share the same data. A MIDlet is an event-based application. All routines executed in the MIDlet are invoked in response to an event reported to the MIDlet by the application manager. The initial event that occurs is when the MIDlet is started and the application manager invokes the startApp() method. The startApp() method in a typical MIDlet contains a statement that displays a screen of data and prompts the user to enter a selection from among one or more options. The nature and number of options is, MIDlet and screen dependent. A Command object is used to present a user with a selection of options to choose from when a screen is displayed. Each screen must have a CommandListener. A CommandListener monitors user events with a screen and causes the appropriate code to execute based on the current event. Here we dicuss about Application Manager Responsibilities which is running on the device which is provided by the Device manufacturer: Installing, executing, and removing a MIDLet Suite. Giving access to classes of the JVM and CLDC for Each member of the MIDlet suite. Makes the Java archive (JAR) file and the Java application descriptor (JAD) file available to members of the MIDlet suite.

3.1) JAR Files

3.1.1)Something About Manifest File: Nine attributes are defined in this file.The first six attributes are necessary. The files extension is changed to .mf when the MIDlet is prepared for deployment. All entries are name:value pairs.

J2ME Application life cycle and difference Between J2SE and J2ME
Each pair must be terminated with a carriage return. Whitespace between the colon and the attribute value is ignored.

Here are Necessary Attributes of a Manifest File : MIDlet-Name: MIDlet suite name. MIDlet-Version: MIDlet version number. MIDlet-Vendor: Name of the vendor who supplied the MIDlet. MIDlet-n: Attribute per MIDlet. Values are MIDlet name, optional icon, and MIDlet class name. MicroEdition-Profile: Identifies the J2ME profile that is necessary to run the MIDlet. MicroEdition-Configuration: Identifies the J2ME configuration that is necessary to run the MIDlet.

Optional Attributes are MIDlet-Icon: Icon associated with MIDlet, must be in PNG image format. MIDlet-Description: Description of MIDlet. MIDlet-Info-URL: URL containing more information about the MIDlet.

3.2) JAD Files

JAD Files are used to pass parameters to a MIDlet without modifying the JAR file . Also used to provide the application manager with additional content information about the JAR file to determine whether the MIDlet suite can be implemented on the device. There are five necessary attributes for a JAD file: 3.2.1)Something About JAD File Files must have the .jad extension. The values of the MIDlet-Name, MIDlet-Version, and MIDlet-Vendor attributes in the JAD file must match the same attributes in the manifest . All entries are name:value pairs.

Necessary Attributes are MIDlet-Name: MIDlet suite name. MIDlet-Version: MIDlet version number. MIDlet-Vendor: Name of the vendor who supplied the MIDlet. MIDlet-n: Location of the JAR file. MIDlet-Jar-URL: Attribute per MIDlet. Values are MIDlet name, optional icon, and MIDlet class name.

Optional attributes available are MIDlet-Jar-Size: Size of the JAR file in bytes. MIDlet-Data-Size: Minimum size (in bytes) for persistent data storage. MIDlet-Description: Description of MIDlet. MIDlet-Delete-Confirm: Confirmation required before removing the MIDlet suite. MIDlet-Install-Notify: Send installation status to given URL.

J2ME Application life cycle and difference Between J2SE and J2ME
3.3) Programs

A MIDlet is a class that extends the MIDlet class and is the interface between application statements and the run-time environment , which is controlled by the application manager . A MIDlet class must contain three abstract methods that are called by the application manager to manage the life cycle of the MIDlet. These abstract methods are. startApp(): called by the application manager when the MIDlet is started and contains statements that are executed each time the application begins execution. Public and have no return value nor parameter list. pauseApp(): called before the application manager temporarily stops the MIDlet. The application manager restarts the MIDlet by recalling the startApp() method. Public and have no return value nor parameter list. destroyApp(): called prior to the termination of the MIDlet by the application manager. Public method without a return value. It has a boolean parameter that is set to true if the termination of the MIDlet is unconditional, and false if the MIDlet can throw a MIDletStateChangeException.

The Basic Midlet Shell.

public class BasicMIDletShell extends MIDlet { public void startApp(){ } public void pauseApp(){ } public void destroyApp( boolean unconditional){ } } MIDP API classes are used by the MIDlet to interact with the user and handle data management. User interactions are managed by user interface MIDP API classes. These APIs prompt the user to respond with an appropriate command. The command causes the MIDlet to execute one of three routines: Perform a computation. Make a network request. Display another screen.

The data-handling MIDP API classes enable the developer to perform four kinds of data routines: Write and read persistent data. Store data in data types. Receive data from and send data to a network. Interact with the small computing devices input/output features.

3.4) Differences Between Core Java and Java for J2ME

Major Differences are : Floating-point math is missing in J2ME. MIDlet cannot use any floating-point data types or calculations.

J2ME Application life cycle and difference Between J2SE and J2ME
Absence of finalize() method in J2ME. Reduced number of error-handling exceptions in J2ME. JVM for small computing devices requires a custom class loader that is supplied by the device manufacturer and cannot be replaced or modified. We cannot group threads. All threads are handled at the object level. The class file verification is replaced with two processes called Preverificaton and Validation. Preverification occurs prior to loading the MIDLets and Validation occurs after loading the MIDLet.

You might also like