java 2 micro edition ( j2me)krugazor.free.fr/ece/ing5/j2me.pdf · java 2 micro edition goals •...

33
Java 2 Micro Edition ( J2ME) 1

Upload: others

Post on 09-Feb-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Java 2 Micro Edition

( J2ME)

1

Page 2: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

• Java platforms

• J2ME history

• J2ME positioning

• J2ME concepts

• J2ME components

• Standardization through CLDC & MIDP

• Exemples

Heads up

2

Page 3: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Java Platforms

3

Page 4: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

History

• 1998 : Sun Microsystems Laboratories rolls out the "Spotless" research project.

• Stated goals :

- Assessment on Java usability for embedded platforms.

- Development resources for a VM that has the following particularities :

. Small

. Portable

. Ease of use and development

4

Page 5: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

History (continued)

• June, 1999 : Sun Microsystems Laboratories presents Java 2 Micro Edition (J2ME)

• October 1999 : Standardization protocols for J2ME components start

5

Page 6: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Java 2 Micro EditionGoals

• End-user hardware appliances and services have a stable base for new applications and services to build onto

• Hardware makers can let others develop standardized applications for their devices

• Users can dynamically download and install full-featured applications on a wide range of devices

6

Page 7: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Devices

7

Page 8: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Devices (continued)

• Mobile phones

• PDAs

• TV receivers/decoders

• Gaming consoles

• Bank terminals

• Vehicle-embedded appliances

• Wearable computer

8

Page 9: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Device constraints

• Limited user interaction (no keyboard/mouse, ...)

• Limited displays (size, color, ...)

• Limited memory

• Communication

• Limited power (battery)

• Size constraints (small, light, ...)

• Shock-resistant

9

Page 10: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Configuration

• A configuration defines a minimal platform for a given category of devices, based on processing power and memory

• A configuration defines the smallest set of functionalities to be in the Java platform. It generally applies to a very wide scope of devices.

10

Page 11: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Existing Configurations

• Connected Device Configuration (CDC)

• Connected Limited Device Configuration (CLDC)

11

Page 12: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Connected Device Configuration (CDC)

• Identifies end-user "top of the range" devices

• Hardware specifications :

- Wide range of user interaction devices

- Total memory > 512 KB

- 32 bits CPU

- Stable connection to a broadband network access

• Exemples : TVs et Internet videophones, navigation systems, entertainment appliances.

12

Page 13: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Connected Limited Device Configuration (CLDC)

• Identifies end-user "low class" devices

• Hardware specifications :

• Memory : 128 KB to 512 KB of available memory for Java processes

• 16 or 32 bits CPU

• Battery powered devices, low consumption

• Small bandwidth on a potentially intermittent cconnection

• Exemples : mobile phones, pagers, PDAs, barcode readers, ...

13

Page 14: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

J2SE & Configurations

J2SE

CDC CLDC

14

Page 15: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Profile

• A profile is a layer on top of a configuration

• A profile gives a common platform for a family of devices

• A profile specifies a set of functionalities

• A profile may have additional librairies

15

Page 16: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Existing profiles

• CDC profiles

- Foundation Profile JSR-46

- Personal Profile JSR-62

- Personal Basis Profile JSR-129

- RMI Profile JSR-66

- Game Profile JSR-134

• CLDC profiles

- Mobile Information Device Profile (MIDP) JSR-37 et JSR-118

16

Page 17: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Mobile Information Device Profile (MIDP)

• Specifications

• Memory : 128 KB of non-volatile memory for MIDP components, 8 KB of non-volatile memory for persistant data, and 32 KB of memory of volatile memory

• Display : 96 x 54, 1 bit

• User interaction : Keyboard (one or two hands), touch-screen

• Network : Both ways, wireless, intermittent, small bandwidth

17

Page 18: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Existing VMs• CDC Configuration

- CVM (Sun)

- JVM (Sun)

- J9 (IBM)

• CLDC Configuration

- KVM (Sun)

- Monty (Sun)

- MicrochaiVM (HP)

- JBED (Esmertec)

18

Page 19: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Kuaui Virtual Machine (KVM)

• 16 & 32 bits CPU

• Specifications :

- ~ 60 KB of static memory usage

- Highly portable, fully documented

- Module based for good customization

- As fast and complete as possible

• Supported OS

- Windows CE

- Solaris Operating Environment

- Palm OS

19

Page 20: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Architecture

Card VM

Système d’exploitation

JVM KVM

Java Card API

CLDCCDC

J2SEJava 2

Standard Edition

J2EEJava 2

Entreprise Edition

PackagesOptionnels

PackagesOptionnels

MobileInformation

DeviceProfile

Profils

J2ME

20

Page 21: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

CLDC & MIDPStandardization

• Java Application :

- A Java application is a class collection in which one of the classes has a main method : public static void main(String[] args)

• Application handling

- Download and install applications

- Inspect existing applications on the device

- Select and execute applications

- Uninstall existing applications

21

Page 22: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

CLDC & MIDPStandardization

• Java - No floating point unit

- No finalize

- Limited exceptions

• KVM- No FPU

- No JNI

- No dynamic class loader

- No reflexivity

- No finalize

- No thread groups

22

Page 23: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Architecture CLDC & MIDP

Applications MIDP

ApplicationsOEM

MIDP

CLDC (KVM)

Système d’exploitation

APIOEM

23

Page 24: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

ApplicationLife-Cycle

24

Page 25: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Compilation"javac" takes java files, andcompiles them into class files

MyApp.java

MyApp.class

MyApp.class

javac

preverifier

interpreter

runtimeverifier

Development hardware

KVM runtime

Download

25

Page 26: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Pre-verificationTakes the program and runs it against a "simulated" environment to ensure maximum compatibility

MyApp.java

MyApp.class

MyApp.class

javac

preverifier

interpreter

runtimeverifier

Developmenthardware

KVM runtime

Download

26

Page 27: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Execution (Phase 1)

• The runtime verifier looks up the sent bytecode and checks for compatibility

• If this verification fails, the program won't run

MyApp.java

MyApp.class

MyApp.class

javac

preverifier

interpreter

runtimeverifier

Developmenthardware

KVM runtime

Download

27

Page 28: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Execution (Phase 2)

• If the verification completes successfully, the classes are loaded

• Interpretation (execution) can now start

MyApp.java

MyApp.class

MyApp.class

javac

preverifier

interpreter

runtimeverifier

Development hardware

KVM runtime

Download

28

Page 29: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Application cycle

A Java MIDP application is called a « MIDlet »

• States of a « MIDlet »– « Active » – « Pause » – « Destroy »

Pause

Active

Destroyed

startApp

destroyApp

pauseApp

destroyApp

29

Page 30: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Exemplepackage examples;import javax.microedition.midlet.*;import.javax.microedition.lcdui.*;

Public class HelloMIDlet extends MIDlet implements CommandListener { private Command exitCommand; private Ticker hi = new ("J2ME is cool"); public HelloMIDlet() { exitCommand = new Command("Exit", Command.EXIT, 1);

public void startApp() { TextBox tb = new TextBox("Hello MIDlet ","Wireless Internet",256, 0); tb.addCommand(exitCommand); tb.setTicker(hi); tb.setCommandListener(this); Display.getDisplay(this).setCurrent(tb); } public void pauseApp() {} public void destroyApp(boolean unconditional){} public void commandAction(Command c, Displayable d) { if (c == exitCommand) { destroyApp(false); notifyDestoyed(); } }}

30

Page 31: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Result

31

Page 32: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

Application Exemples

32

Page 33: Java 2 Micro Edition ( J2ME)krugazor.free.fr/ece/ING5/J2ME.pdf · Java 2 Micro Edition Goals • End-user hardware appliances and services have a stable base for new applications

References

• J2ME : http://java.sun.com/j2me/

• CDC : http://java.sun.com/products/cdc/

• CLDC : http://java.sun.com/products/cldc/

• MIDP : http://java.sun.com/products/midp/

• Java Community Process : http://jcp.org/en/jsr/overview

33