Java 2 Platform, Micro Edition (J2ME

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 35

Java 2 Platform, Micro Edition (J2ME)

Rahul Pol.

J2ME

Java Editions
Different devices have different requirements and

different expectations of Java. One platform (solution) cannot address all the market segments (web server, video games etc.) Users/developers want flexibility. They want to choose what they want to use and what they do not.

J2ME

Java Editions
The Java 2 Platform is split into three editions. Each edition provides a complete environment for

running Java-based applications, including the Java virtual machine (VM) and runtime classes. The three editions target different kinds of applications running on different kinds of devices.

J2ME

Java Editions
Java2 Standard Edition (J2SE)

Java 2 Platform

Java2 Enterprise Edition (J2EE)

Java2 Micro Edition (J2ME)

Standard desktop & workstation applications

Heavy duty server systems

Small & memory constrained devices

J2ME

Java Editions
Each edition defines different sets of class libraries.
There are thousands of core J2SE runtime classes, taking up to 10-20 megabytes

of space. J2ME-based devices have fewer classes.

J2EE J2SE

J2ME

J2ME

J2ME Core Concepts


J2ME is based on 3 core concepts: Configurations Profiles Optional packages

J2ME

Configurations
A configuration is a complete Java runtime

environment, consisting of:


Java virtual machine (VM) to execute Java bytecode Native code to interface to the underlying system Set of core Java runtime classes

To use a configuration, a device must meet certain

minimum requirements.

J2ME

Configurations
Configuration

Connected Limited Device Configuration

CLDC

Connected Device Configuration

CDC

J2ME

CLDC vs. CDC


CLDC
For very constrained devices

CDC
2 MB or more memory

for Java platform 32-bit processor 160 - 512 KB of total memory High bandwidth 16-bit or 32-bit processor network connection, Low power consumption and most often using often operating with battery power TCP/IP Connectivity with limited bandwidth

J2ME

J2ME Core Concepts


J2ME is based on 3 core concepts: Configurations Profiles Optional packages

J2ME

10

Profiles
Adds domain-specific classes to a configuration:
To fill in missing functionality To support specific uses of a device

Most profiles define user interface classes for building interactive applications. To use a profile, the device must meet the minimum requirements of the underlying configuration and of the profile.

J2ME

11

Profiles
MIDP PDAP

Profile

FP

PBP

PP

Mobile Information Device Profile

Personal Digital Assistant Profile

Foundation Profile

Personal Basis Profile

Personal Profile

J2ME

12

J2ME Core Concepts


J2ME is based on 3 core concepts: Configurations Profiles Optional packages

J2ME

13

Optional Packages
Set of APIs in support of additional, common

behaviors. Have specific dependencies on a particular configuration and/or one or more profiles. Examples of optional packages :
RMI Optional Package Bluetooth Optional Package

JDBC Optional Package

J2ME

14

MIDlets The heart of J2ME


MIDP does not support the running of applications

that use a static main method as their entry point, nor calling the System.exit method in order to terminate. Instead, we use a MIDlet, which is a MID Profile application.

J2ME

15

MIDlets The heart of J2ME


Every application must extend

javax.microedition.midlet.MIDlet class to allow the application management software to:


control the MIDlet be able to retrieve properties from the application

descriptor notify and request state changes

J2ME

16

MIDlets The heart of J2ME


The extending class is the main class of the

application. The MIDlet class defines abstract methods that the main class implements (for example: startApp(), destroyApp(), notifyDestroyed()).

J2ME

17

MIDlet Suite
One or more MIDlets are packaged together into a

MIDlet suite, composed of:


JAR (Java archive) file JAD (Java Application Descriptor) file

All the user-defined classes and resources required by

the suite's MIDlets must be in the JAR file.

J2ME

18

Sample classes API


MIDlet Base class
Form Command CommandListener ItemCommandListener Item

J2ME

19

MIDlet class API


protected abstract void startApp()
protected abstract void pauseApp() protected abstract void

destroyApp(boolean unconditional) public final void notifyDestroyed()

J2ME

20

Sample classes API


MIDlet

Form
Command CommandListener ItemCommandListener Item

J2ME

21

Form class
A Form is a Screen that contains an arbitrary mixture of items: images, read-only text fields, editable text fields, editable date fields, gauges, choice groups, and custom items.
In general, any subclass of the Item class may be contained within a form. The implementation handles layout, traversal, and scrolling.

J2ME

22

Form class API


Item management
public int append(Item item) public Item get(int itemNum)

Layout
public void

setItemStateListener(ItemStateListener iListener)

J2ME

23

Sample classes API


MIDlet
Form

Command
CommandListener
ItemCommadListener

Item

J2ME

24

Command class
The Command class represents the semantic meaning of an action. Command objects are presented in the user interface. The action itself is implemented in a CommandListener object. The CommandListener is associated with a Displayable or an Item. Once the Command is called the CommandListener is invoked, and the action is performed.
J2ME 25

Command class
Command label

public String getLabel() Command type

public int getCommandType() Command priority


public int getPriority()

J2ME

26

CommandListener class API


This object is a listener for Commands that are

attached to a Displayable. public void commandAction(Command c, Displayable d)

J2ME

27

ItemCommandListener class API


When a command (attached to an Item) is invoked,

the application is notified by having the commandAction() method called on the ItemCommandListener that had been set on the Item. public void commandAction(Command c, Item item)

J2ME

28

Sample classes API


MIDlet
Form Command CommandListener ItemCommandListener

Item

J2ME

29

Item class
A superclass for components that can be added to a

Form. All Item objects have a label field Choose the Items layout, size, and appearance Attach Commands

J2ME

30

Item class API


public void

setDefaultCommand(Command cmd) public void setItemCommandListener(ItemCommandListe ner listener) public void notifyStateChanged() public int getPreferredWidth()

J2ME

31

Getting Started
1st step: Download suns J2ME Wireless

Toolkit from:
http://java.sun.com/products/j2mewtoolkit/download. html

2nd step: Make sure you have J2SE SDK

installed 3rd step: Install the J2ME Toolkit.

J2ME

32

Distribution to actual devices


Create a package
Place your code somewhere on the net. Update .jad file

Download the application to your mobile


Start playing

J2ME

33

Some other issues


OTA provisioning
Using Servlets Working with EclipseME

Web services

J2ME

34

The END!
You can download all the demos JARs from:

www.cs.huji.ac.il/~kerengaz/j2me/
Have Fun!!!

J2ME

35

You might also like