Download JavaTM 2 Platform, Micro Edition (J2ME)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
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)
The Architecture of J2ME
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
Overview
MIDP Interface
MIDP
CLDC (Java)
KVM (C)
KVM OS Interface
Native OS & Apps
Java Application Manager
CLDC Interface
Native Call
J2ME
MIDlet 1MemoryMIDlet 2
Native Interface
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.*:
 java.util.*:
IllegalStateException
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
Steps Flowchart
Edit Source Code
*.java
Compile and Preverify
*.class
Emulator
Resources:text,
image,…
*.class Archive *.jar
MIDlet
Manifest File
Download
To Device
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
New()
Paused
pauseApp()
destroyApp()
Destroyed
startApp()
Active
destroyApp()
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 files
Preverify the class files
Package:
 Jar
up the verified class files
 Jar up the resource files
Running the Midlet
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 twoway 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