Title: J2ME MIDP2.0
1J2ME MIDP2.0
2What is J2ME?
- Java 2 Micro Edition
- Specially cut down version of Java for mobile
devices, such as mobile phones, PDAs, Set Top
Boxes. - It combines a resource-constrained JVM (Java
Virtual Machine) and a set of Java APIs for
developing applications for mobile devices.
3J2ME Configurations - 1
- 2 configurations
- Connected Limited Device Configuration (CLDC)
- 16-32bit
- 160kb 512 kb memory
- Battery powered
- Inconsistent
- Small-bandwidth network wireless connection
- May not have user interface (UI)
- Pagers, PDA, cell phone, Dedicated terminals,
handheld consumer devices with 128kb and 512of
memory
4J2ME Configuration - 2
- Connected Device Configuration (CDC)
- gt 2Mb memory
- Implement the complete JVM also called the
Compact Virtual Machine (CVM) - Digital setup boxes
- home appliances
- navigation systems
- point-of-sale terminal
- smart phone
5What is J2ME?
- In CLDC, many features such as floating-point
support are missing, due to capabilities of the
device. - Extra features such as a GameAPI are now included
for mobile development. - Unlike windows, a java virtual machine comes
pre-installed on the phone.
6Why J2ME?
- Supported by over 1Billion handsets
- Device independent
7J2ME Development
- Sun Wireless Toolkit WTK
- Several IDEs Available
- NetBeans
- Eclipse
- Sun One
- Borland JBuilder
8Core and Optional Packages
- J2ME can be divided in 3 parts
9CLDC / CDC
- A profile is a superset of a configuration, of
which there are currently two - Connected Limited Device Configuration CLDC
- and
- Connected Device Configuration CDC
10MIDP
- It implements a profile such as MIDP for mobile
devices or foundation profile for embedded
devices like set-top boxes
11Optional Packages
- Several Optional Packages
- MMAPI
- PIM / File Connection
- WMAPI
- 3D API
- Bluetooth
12Fragmentation?
- Implementation of optional packages varies across
devices and manufacturers. - Nokia and Sony Ericsson provide consistent
approach - Other manufacturers vary
- See comparative table on blackboard
13Specifications
- Visit developer sites for device specifications
14Official Developer Sites
- Nokia www.forum.nokia.com
- Samsung http//developer.samsungmobile.com/eng/fro
nt_zone/bbs/bbs_main.jsp?p_menu_id1500 - Motorola http//developer.motorola.com/
- Sony Ericsson http//developer.sonyericsson.com/
- Microsoft http//www.microsoft.com/windowsmobile/d
evelopers/default.mspx - Blackberry http//www.blackberry.com/developers/in
dex.shtml - Siemens https//market.benqmobile.com/portal/main.
aspx?LangID0pid1 - Orange Partner
- http//www.orangepartner.com/site/enuk/home/p_hom
e.jsp
15MIDlets
- A Java program created for Mobile Devices (J2ME
application) - MIDlets will (should) run on any device that
implements J2ME MIDP - Like all Java programs, MIDlets are "compile
once, run anywhere - MIDlet .jar file
16MIDlet Reqs
- A MIDlet has to fulfill the following
requirements in order to run on a mobile phone - The main class needs to be a subclass of
javax.microedition.midlet.MIDlet - The MIDlet needs to be packed inside a .jar file
(e.g. by using the jar-tool) - The .jar file needs to be pre-verified by using a
preverifier.
17MIDlet Development Process
18MIDlet
- A MIDlet is a set of classes designed to be run
and controlled by the application management
software - The application must extend this class to allow
the AMS to control the MIDlet and to be able to
retrieve properties from the application
descriptor and notify and request state changes.
19MIDlet
- The methods of this class allow the AMS to
- Create
- Start
- Pause
- and destroy a MIDlet.
20MIDlet Life Cycle
21Basic MIDlet
- MainMidlet.java
- //classes needed for MIDlet execution
- import javax.microedition.midlet.
- import javax.microedition.lcdui.
- public class MainMidlet extends MIDlet
-
- public void startApp()
- //start application from here
- //set the display
-
-
- public void pauseApp()
- //pause application
-
-
- public void destroyApp(boolean unconditional)
- //stop application
22MIDlet Functions
- A MIDlet needs to have the following
- functions in order to compile
- startApp() this runs when the MIDlet is started
- pauseApp() this runs when the application is
paused e.g. incoming call - destroyApp() this runs when the MIDlet /
application is closed
23MIDlet States and Events
24MIDP GUI - Display Classes
- Different from J2SE (Java Standard Ed.)
- AWT and swing not implemented!
25High Level GUI
- Screens, forms, lists, choice, text fields
- all of these inherit
- javax.microedition.lcdui.Screen
- Easy to program pre-defined objects
- Not very flexible difficult to customize
objects - Unsuitable for multimedia applications although
it can be used for menus and settings
26GUI Display Classes
27Examples of High-Level GUI
28Low Level GUI
- Canvas
- Base class for writing applications that need to
handle low-level events and to issue graphics
calls for drawing to the display. - Full control over screen display.
- Ability to process events and key presses.
29Low Level GUI
- Canvas Game Canvas
- (A subclass of Canvas)
- provides the basis for a game user interface
- provides game-specific capabilities such as
- an off-screen graphics buffer
- the ability to query key status.
30/ MainMidlet.java / import
javax.microedition.midlet. import
javax.microedition.lcdui. public class
MyMidlet extends MIDlet //variable for
display private Display display //create
new MyGameCanvas private MyGameCanvas mgc
new MyGameCanvas() public void
startApp() // find current display
this.display Display.getDisplay( this )
// attach myGameCanvas to display
this.display.setCurrent(mgc) //start app
public void pauseApp() //pause app
public void destroyApp(boolean
unconditional) // Clear up resourses
notifyDestroyed() //destroyApp //end
class
/ MyGameCanvas.java / //import necessary
graphics classes import javax.microedition.lcdui.
game. import javax.microedition.lcdui.
public class MyGameCanvas extends GameCanvas
/ Creates a new instance of
MyGameCanvas / public MyGameCanvas()
super(true) //constructor public
void paint(Graphics g) /clear the screen
call this method anytime you wish to refresh the
gfx/ flushGraphics() //set the
colour to black in RGB values
g.setColor(0,0,0) / Draws the Hello
world string at x0, y0 location, the text is
aligned to the top left of the screen./
g.drawString("Hello World!!!",0,0,Graphics.T
OPGraphics.LEFT) //paint //class
31J2ME Online Resources
- Forum Nokia
- Orange
- Sony Ericsson
- Motorola
- Sun J2ME
- Several others available