java 2 platform, micro edition (j2me)
DESCRIPTION
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?. - PowerPoint PPT PresentationTRANSCRIPT
Java 2 Platform,Micro Edition (J2ME)
By Xiaorong Wang
Agenda
IntroductionCLDC and MIDPProgramming with CLDC/MIDPSummary 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 resourcesLimited screen size, memory, and processing powerPDAs, cell phones, other consumer electronic and embedded devices
ConfigurationThe foundation of J2ME is configurationsA configuration defines Java APIs and a specification of a java virtual machineA configuration defines a minimum Java platform for a family of devices
Two Types of Configuration
Connected device configuration (CDC)Connected limited device configuration (CLDC)
The Architecture of J2ME
Profiles
On top of the configurations are the profilesMobile Information Device Profile (MIDP)The foundation configuration is CLDCMIDP is a profile for mobile information
devices, such as: cellular phones, two-way pagers, and PDAs
Agenda
IntroductionCLDC and MIDPProgramming with CLDC/MIDPSummary and Resources
Overview
Native OS & AppsNative Interface
KVM OS Interface
CLDC (Java)KVM (C)
Native C
all
CLDC Interface
J2M
E MIDPMIDP Interface
Memory
Java Application Manager
MIDlet 1 MIDlet 2
Connected, Limited Device Configuration
(CLDC)Targets at devices with160KB to 512KB total memory available
for Java technologyLimited 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 compatibilityLanguage-level different: Floating point not supported in CLDC 1.0CLDC libraries are limited
CLDC LibrariesClasses 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: OverviewMobile Information Device Profile (MIDP) coversTimersApplication lifecyclePersistent storageNetworkingUser interface
MIDP: LibrariesClasses inherited from J2SE:java.lang.*: IllegalStateExceptionjava.util.*: Timer, TimerTask
New classes introduced by MIDP:javax.microedition.rms.*javax.microedition.midlet.*javax.microedition.io.*javax.microedition.lcdui.*
Agenda
IntroductionCLDC and MIDPProgramming with CLDC/MIDPSummary and Resources
Steps Flowchart
Edit Source CodeEdit Source Code
Compile and PreverifyCompile and Preverify
EmulatorEmulator
*.java
*.class
ArchiveMIDlet
DownloadTo Device
*.jar*.class
Resources:text, image,…
Manifest File
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 satisfy the 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
PausedPaused
ActiveActive
DestroyedDestroyedpauseApp()
startApp()
destroyApp()
destroyApp()
New()
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)
Using the KToolBar
KToolBar
Building the MIDlet
Compile the Java source filesPreverify the class filesPackage:Jar up the verified class filesJar up the resource files
Running the Midlet
Agenda
IntroductionCLDC and MIDPProgramming with CLDC/MIDPSummary and Resources
SummarySome 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/j2mehttp://www.javaworld.com