310 likes | 533 Views
Java 2 Platform, Micro Edition (J2ME). By Xiaorong Wang. Agenda. Introduction CLDC and MIDP Programming with CLDC/MIDP Summary and Resources. Java TM 2 Platform. Java 2 Enterprise Edition (J2EE) Java 2 Standard Edition (J2SE) Java 2 Micro Edition (J2ME). What is J2ME?.
E N D
Java 2 Platform,Micro Edition (J2ME) By Xiaorong Wang
Agenda • Introduction • CLDC and MIDP • Programming with CLDC/MIDP • Summary and Resources
JavaTM 2 Platform • Java 2 Enterprise Edition (J2EE) • Java 2 Standard Edition (J2SE) • Java 2 Micro Edition (J2ME)
What is J2ME? • Java 2 Micro Edition (J2ME) is Sun’s version of Java aimed at machines with limited hardware resources • Limited screen size, memory, and processing power • PDAs, cell phones, other consumer electronic and embedded devices
Configuration • The foundation of J2ME is configurations • A configuration defines Java APIs and a specification of a java virtual machine • A configuration defines a minimum Java platform for a family of devices
Two Types of Configuration • Connected device configuration (CDC) • Connected limited device configuration (CLDC)
Profiles • On top of the configurations are the profiles • Mobile Information Device Profile (MIDP) • The foundation configuration is CLDC • MIDP is a profile for mobile information devices, such as: cellular phones, two-way pagers, and PDAs
Agenda • Introduction • CLDC and MIDP • Programming with CLDC/MIDP • Summary and Resources
Memory MIDP Interface MIDP J2ME CLDC Interface KVM OS Interface CLDC (Java) KVM (C) Native Call Native Interface Native OS & Apps Java Application Manager Overview MIDlet 1 MIDlet 2
Connected, Limited Device Configuration (CLDC) • Targets at devices with • 160KB to 512KB total memory available for Java technology • Limited power (often battery) • Limited connectivity to a network (often wireless) • Extremely constrained UI, small screens
CLDC Language and VM Compatibility • Full Java Language and Java Virtual Machine Specification compatibility • Language-level different: Floating point not supported in CLDC 1.0 • CLDC libraries are limited
CLDC Libraries • Classes inherited from Java 2 Platform, Standard Edition (J2SE version 1.3) are in packages: • java.lang.* • java.util.* • java.io.* • New classes introduced by CLDC: • javax.microedition.*
MIDP: Overview • Mobile Information Device Profile (MIDP) covers • Timers • Application lifecycle • Persistent storage • Networking • User interface
MIDP: Libraries • Classes inherited from J2SE: • java.lang.*: IllegalStateException • java.util.*: Timer, TimerTask • New classes introduced by MIDP: • javax.microedition.rms.* • javax.microedition.midlet.* • javax.microedition.io.* • javax.microedition.lcdui.*
Agenda • Introduction • CLDC and MIDP • Programming with CLDC/MIDP • Summary and Resources
Resources:text, image,… *.java *.class *.jar *.class Manifest File Steps Flowchart Edit Source Code Archive MIDlet Download To Device Compile and Preverify Emulator
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class HelloMidlet extends MIDlet implements CommandListener { // Initialize the Midlet Display variable private Display midletDisplay; // Initialize a variable for the doneCommand private Command doneCommand; public HelloMidlet() { // Retrieve the display from the static display object midletDisplay = Display.getDisplay(this); // Initialize the doneCommand doneCommand = new Command("DONE", Command.SCREEN, 1); }
public void startApp() { // Create the TextBox containing the "Hello Midlet World!!" message TextBox textBox = new TextBox("Hello Midlet", "Hello Midlet World!!", 256, 0); // Add the done Command to the TextBox textBox.addCommand(doneCommand); // Set the command listener for the textBox to the current midlet textBox.setCommandListener( (CommandListener) this); // Set the current display of the midlet to the textBox screen midletDisplay.setCurrent(textBox); } public void pauseApp() { } public void destroyApp(boolean unconditional) { }
/* The commandAction method is implemented by this * midlet to satisfythe CommandListener interface and * handle the done action. */ public void commandAction(Command command, Displayable screen) { // If the command is the doneCommand if (command == doneCommand) { // Call the destroyApp method destroyApp(false); // Notify the midlet platform that the midlet has completed notifyDestroyed(); } } }
Life Cycle Of Midlet New() Paused destroyApp() pauseApp() Destroyed startApp() destroyApp() Active
Developing Tools • Java 2 Standard Edition, version 1.3.0 or higher (http://java.sun.com/j2se/1.3) • J2ME Wireless Toolkit (http://java.sun.com/products/j2mewtoolkit)
Building the MIDlet • Compile the Java source files • Preverify the class files • Package: • Jar up the verified class files • Jar up the resource files
Agenda • Introduction • CLDC and MIDP • Programming with CLDC/MIDP • Summary and Resources
Summary Some of the companies that making J2ME products: • Research in Motion (RIM): Blackberry two-way handhelds • Nokia: Mobile phones • NEXTEL: Mobile phones – i85s and i50sx • American Express: Java Card for its Blue credit cards
Resources • http://java.sun.com/j2me • http://www.javaworld.com