Introduction
J2ME TUTORIAL:
J2ME (Java 2 Platform, Micro Edition) is a technology that allows programmers to use theJava programming language and related tools to develop programs for mobile wireless information devices such as cellular phones and personal digital assistants (PDAs). J2ME consists of programming specifications and a special virtual machine, the K Virtual Machine that allows a J2ME-encoded program to run in the mobile device.
Since 1995, Java has grown into a complete and mature object-oriented development platform that allows easy and fast applications development for a great many hardware and software platforms, thereby significantly lowering cost of application development and maintenance.
In 1999, Sun divided Java into three separate editions. Java 2, Standard Edition (J2SE) is intended for use on common personal computers. Java 2, Enterprise Edition (J2EE) is designed for use on servers. Java 2, Micro Edition (J2ME) is designed for small devices with a limited processor power and small memory size. Mobile phones, personal digital assistants (PDAs), consumer electronics, and embedded devices are common examples of J2ME capable devices.
J2ME combines a resource constrained JVM and a set of Java APIs for developing applications for mobile devices.
J2ME can be divided into three parts, as shown in Figure 1: a configuration, a profile, and optional packages. A configuration contains the JVM (not the traditional JVM, but the cut-down version) and some class libraries; a profile builds on top of these base class libraries by providing a useful set of APIs; and optional packages, are well, an optional set of APIs that you may or may not use when creating your applications. Optional packages are traditionally not packaged by the device manufacturers, and you have to package and distribute them with your application. The configuration and profile are supplied by the device manufacturers and they embedded them in the devices.
The most popular profile and configuration that Sun provides are the Mobile Information Device Profile (MIDP) and Connected Limited Device Configuration (CLDC), respectively. As the name suggests, CLDC is for devices with limited configurations; for example, devices that have only 128 to 512KB of memory available for Java applications. Consequently, the JVM that it provides is very limited and supports only a small number of traditional Java classes. (This limited JVM is actually called the KVM.) Its counterpart, the Connected Device Configuration (CDC) is for devices with at least 2MB of memory available and supports a more feature-rich JVM (but still not a standard JVM).
The MID profile complements the CLDC configuration very well because it minimizes both the memory and power required for limited devices. It provides the basic API that is used for creating application for these devices. For example, it provides thejavax.microedition.lcdui package that allows us to create the GUI elements that can be shown on a (limited) device running the MID profile on top of a CLDC configuration. Note that MIDP cannot be used with CDC devices. CDC devices get their own set of profiles, like the Foundation and Personal profiles. However, I will not cover these profiles or the CDC here, and will concentrate on using MIDP and CLDC only.
The latest versions of MIDP and CLDC are 2.0 and 1.1, respectively. Not many devices currently support these versions, but the list is growing rapidly.
MIDlet Lifecycle
A MIDlet lifecycle have following steps...
startApp()
pauseApp()
destroyApp()
By default MIDlet is in the paused states. When the application is executed by default startApp()method will call and when close the application the destroyApp() method will be called. But when your constructor is not null type then it will be executed firstly. The source code of life cycle execution is as follows:
Steps to run MIDlet:
Step 1: Go to Windows start panel and choose" Wireless Toolkit 2.5.1: Start > Programs > Sun Java Wireless Toolkit 2.5.1 for CLDC > Wireless Toolkit 2.5.1. The console window appears like this.
Step 2: Now, Click the New Project on the toolkit menu bar, then a new project box opens. Fill the appropriate Project name and MIDlet class Name of your choice. After that, click Create Project button.
Step 3: Now, Click the New Projecton the toolkit menu bar, then a new project box opens. Fill the appropriate Project name GARDI_VIDHYAPITH and MIDlet class Name HelloWorld of your choice. After that, click Create Project button.
Step 4: Then a Settings for project window appears. For default settings, click OK.
STEP 5: NOTE: PUT YOUR JAVA PROGRAM IN src FOLDER
C:\Documents and Settings\Administrator\j2mewtk\2.5.2\apps\GARDI_VIDHYAPITH\src
Step 6: Next click the Build button from the toolkit menu bar. These causes the Sun Java Wireless Toolkit for CLDC to compile and preverify the Java source files. The whole build process is shown below.
Step 7: Next click the Run Button from the toolkit menu bar. This executes the compiled Java class files on the emulator.
srilekha,yamuna.srilekha@gmail.com,it branch
ReplyDeletesrilekha,yamuna.srilekha@gmail.com,it branch
ReplyDelete