+ All Categories
Home > Documents > Java 2 Platform, Micro Edition (J2ME)

Java 2 Platform, Micro Edition (J2ME)

Date post: 24-Jan-2016
Category:
Upload: arama
View: 43 times
Download: 0 times
Share this document with a friend
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 Presentation
30
Java 2 Platform, Micro Edition (J2ME) By Xiaorong Wang
Transcript
Page 1: Java 2 Platform, Micro Edition (J2ME)

Java 2 Platform,Micro Edition (J2ME)

By Xiaorong Wang

Page 2: Java 2 Platform, Micro Edition (J2ME)

Agenda

IntroductionCLDC and MIDPProgramming with CLDC/MIDPSummary and Resources

Page 3: Java 2 Platform, Micro Edition (J2ME)

JavaTM 2 Platform

Java 2 Enterprise Edition (J2EE)Java 2 Standard Edition (J2SE)Java 2 Micro Edition (J2ME)

Page 4: Java 2 Platform, 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

Page 5: Java 2 Platform, Micro Edition (J2ME)

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

Page 6: Java 2 Platform, Micro Edition (J2ME)

Two Types of Configuration

Connected device configuration (CDC)Connected limited device configuration (CLDC)

Page 7: Java 2 Platform, Micro Edition (J2ME)

The Architecture of J2ME

Page 8: Java 2 Platform, Micro Edition (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

Page 9: Java 2 Platform, Micro Edition (J2ME)

Agenda

IntroductionCLDC and MIDPProgramming with CLDC/MIDPSummary and Resources

Page 10: Java 2 Platform, Micro Edition (J2ME)

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

Page 11: Java 2 Platform, Micro Edition (J2ME)

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

Page 12: Java 2 Platform, Micro Edition (J2ME)

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

Page 13: Java 2 Platform, Micro Edition (J2ME)

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.*

Page 14: Java 2 Platform, Micro Edition (J2ME)

MIDP: OverviewMobile Information Device Profile (MIDP) coversTimersApplication lifecyclePersistent storageNetworkingUser interface

Page 15: Java 2 Platform, Micro Edition (J2ME)

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.*

Page 16: Java 2 Platform, Micro Edition (J2ME)

Agenda

IntroductionCLDC and MIDPProgramming with CLDC/MIDPSummary and Resources

Page 17: Java 2 Platform, Micro Edition (J2ME)

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

Page 18: Java 2 Platform, Micro Edition (J2ME)

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); }

Page 19: Java 2 Platform, Micro Edition (J2ME)

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){}

Page 20: Java 2 Platform, Micro Edition (J2ME)

/* 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(); } }}

Page 21: Java 2 Platform, Micro Edition (J2ME)

Life Cycle Of Midlet

PausedPaused

ActiveActive

DestroyedDestroyedpauseApp()

startApp()

destroyApp()

destroyApp()

New()

Page 22: Java 2 Platform, Micro Edition (J2ME)

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)

Page 23: Java 2 Platform, Micro Edition (J2ME)

Using the KToolBar

Page 24: Java 2 Platform, Micro Edition (J2ME)
Page 25: Java 2 Platform, Micro Edition (J2ME)

KToolBar

Page 26: Java 2 Platform, Micro Edition (J2ME)

Building the MIDlet

Compile the Java source filesPreverify the class filesPackage:Jar up the verified class filesJar up the resource files

Page 27: Java 2 Platform, Micro Edition (J2ME)

Running the Midlet

Page 28: Java 2 Platform, Micro Edition (J2ME)

Agenda

IntroductionCLDC and MIDPProgramming with CLDC/MIDPSummary and Resources

Page 29: Java 2 Platform, Micro Edition (J2ME)

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

Page 30: Java 2 Platform, Micro Edition (J2ME)

Resources

http://java.sun.com/j2mehttp://www.javaworld.com


Recommended