0% found this document useful (0 votes)
16 views

JavaME 01 Overview

Java J2ME Java Symbian OS

Uploaded by

Imran S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

JavaME 01 Overview

Java J2ME Java Symbian OS

Uploaded by

Imran S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Java™ Platform, Micro Edition

Part 1 – Introduction to Java ME, CLDC


and MIDP

1
What is it all about?

Java Platform

5
The Java Platform, Part 1 / 3

● Java programming language


● Compared to C++:
No pointers
Automatic garbage collection
Interfaces instead of multiple inheritance
Comes with an extensive library

6
The Java Platform, Part 2 / 3

● Virtual Machine (JVM)


Executes compiled Java bytecode (.class)
Available for many systems
Controls the code (security)

● Often used for mobile phones:


Kilobyte Virtual Machine (KVM)
Memory footprint starting at only 60 kB (+)

● Now being replaced by Hotspot JVMs.


7
The Java Platform, Part 3 / 3

● Application Programming Interfaces (APIs)


Manifold libraries
e.g. UI, network, 3D, location based services, etc.

8
Java?

● In numbers:
> 6 Billion Java-enabled devices
2.6 Billion Java-enabled phones
(8 out of 10 shipped in 2008)
3.5 Billion Java Cards
20 Million Java set-top boxes
800 Million Java desktops
180 Operators deploying Java content
6 Million developers
9
MSA … Mobile Service Architecture (JSRs 248 and 249)
JTWI … Java Technology for the Wireless Industry, JSR 185
MIDP … Mobile Information Device Profile

Java Editions CDC …


CLDC …
Connected Device Configuration
Connected Limited Device Configuration

Servers & Servers & High-end PDAs, Mobile Smart


enterprise personal TV set-top phones & cards
computers computers boxes, entry-level
embedded PDAs
Optional devices
Packages
Optional
Packages Optional
Packages
Personal Profile Optional
Java 2 Personal Packages
Platform, Java 2 Basis
Platform, MSA
Enterprise Profile
Edition Standard JTWI
Edition Foundation
(J2EE) MIDP
(J2SE) Profile

CDC CLDC Java Card

Java Platform, Micro Edition


(Java ME)
10
Going Mobile

Java ME

11
Differences J2SE / Java ME (MIDP)

● Java ME is mainly a subset of J2SE


But different UI- and event handling functionality
Less utility classes
(only Vector and Hashtable, no LinkedLists, …)
● Code runs on both platforms?
general algorithms: yes
But the whole application needs porting

12
Name: J2ME or Java ME?

● Official name:
Java Platform, Micro Edition (Java ME)
● Former name:
J2ME

13
Configuration

● Defines Java Platform for different device classes:


● CLDC
Limited user interface
Low computing power (usually with a battery)
Network with low bandwidth
● CDC
Network connection with high bandwidth, possibly
persistent
Larger memory requirements
14
CDC

● Equivalent to Java SE 1.4.2 when combined with:


Foundation Profile (FP)
– Extends CDC to Java SE 1.4.2, without graphics and UI
Personal Basis Profile (PBP)
– Lightweight GUI support (AWT subset)
Personal Profile (PP)
– Extends PBP with AWT components and Appled support
● Foundation for Java-based platforms:
(few) smartphones, Blu-Ray, Set-top boxes, etc.
15
CLDC
● Currently available in two versions:
● 1.0
In devices until ~ 2005 (at the latest)
● 1.1
Current standard
Supports floating point
(but mostly in software slow)
Important e.g. for GPS coordinate handling!
● Used for:
Phones (!)
Consumer and entertainment devices
Embedded platforms, controllers, sensors
Sun SPOTs
16
Profiles

● Extension and more detailed specification for a


configuration
● Contains APIs for UI, event handling, data storage,
networks, timers, …
● Minimum requirements for devices (screen size, input
possibilities, ...)
● For mobile phones:
Mobile Information Device Profile (MIDP)

17
Profiles – Major Differences

● MIDP 1.0 ● MIDP 2.1


Tries to improve fragmentation
Hardly any sound support, problems (different version for
limited graphics every phone…)
Only HTTP, no Sockets Stricter specifications for
packages
Many vendor-specific ● MIDP 3.0 (JSR 271)
extensions (bad!)
Multiple MIDlets can run
● MIDP 2.0 concurrently or in the
background, auto-launch
Game API More detailed specifications
Better network and More possibilities for the UI,
support of secondary displays
multimedia support

18
Sample Architecture of a Phone

Profile: MIDP 2.0

Configuration: CLDC 1.1

Virtual Machine: HotSpot

Operating System

19
Java ME – Examples

● Motorola
MOTORAZR V3
CLDC 1.0
MIDP 2.0

20
Java ME – Examples

● Nokia N70
CLDC 1.1
MIDP 2.0

21
Java ME – Examples

● SonyEricsson P990i
CLDC 1.1
MIDP 2.0

CDC 1.0
Personal Profile

22
Java ME – Examples

● Nokia N86 8MP


CLDC 1.1
MIDP 2.1
MSA (Subset)

23
Java ME – Examples

● Amazon Kindle 2
CDC

24
JSRs (Java Specification Requests)

● JSR = CLDC, MIDP or libraries for additional features


● Defined through:
Java Community Process (JCP)
● Examples:
JSR 82: Bluetooth APIs
JSR 179: Location API
JSR 184: Mobile 3D API
JSR 226: Scalable 2D Vector Graphics API

25
JSRs – How Many?

● Sample: supported JSRs of Nokia N86 8MP

26
JSRs – Games?

● A racing game could require:


JSR 184 (3D Graphics)
– 3D world
JSR 135 (Mobile Media)
– Sound
JSR 82 (Bluetooth)
– P2P Gaming
Asphalt 4: Elite Racing HD JSR 180 (SIP)
© Gameloft
– P2P over the network
JSR 229 (Payment)
– New forms of payment

27
JSRs – Mapping Applications?

● A mapping application could require:


JSR 226 (Vector Graphics)
– Map visualization
JSR 179 (Location)
– Where am I?
JSR 172 (Web Services)
– Requesting data
Google Maps Mobile JSR 75 (File and PIM)
© Google
– Map an address
JSR 238 (Internationalization)
– Global software

28
„Write Once, Run Anywhere™“ ?

● Problems:
Different screen sizes
Bugs in manufacturers implementations (!)
Different hardware performance
Which JSRs are supported? Bluetooth? SVG? Web services?…
MIDP 2.0 isn’t strict enough:
– Different key codes for every manufacturer (softkeys, ...)
– Are socket connections available?
– Which sound files are playable? Supported image formats?
– Is double buffering supported?

29
JTWI – Fragmentation Solution?

● Java Technology for the Wireless Industry (JSR 185)


First try of defining full API stack to reduce
fragmentation
Clarification of component JSR specifications
However: too small, too few APIs included
Bad licensing politics
 Failed

30
Mobile Service Architecture
(MSA, JSR 248)
● Goal?
“Umbrella” specification, replace JTWI
Define a unified platform for majority of handsets
– Spec leds: Nokia, Vodafone. Others heavily involved
● Devices started to ship in 2007
With at least subset of MSA

31
Features in MSA for CLDC
Security & Application Personal
Comms Graphics
Commerce Conectivity Information
JSR 82 JSR 226 2D Scalable
Bluetooth Vector Graphics

JSR 180 JSR 184


SIP 3D Graphics

JSR 205 JSR 234 Mobile- JSR 224 JSR 211 JSR 179
MMS Messaging media Supplement Payment Content Handler Location

JSR 120 JSR 135 JSR 177 Security & JSR 172 JSR 75
SMS Messaging Mobile Media Trust Services Web Services PIM & File

Application JSR 185 JSR 118 JSR 238


JTWI MIDP 2.0 I18N
Environment

Virtual JSR 139 Conditional APIs


CLDC 1.1
Machine JTWI APIs
32
MIDP 3.0

● High-level goals
Add much-requested functionality over MIDP 2
Rework security model to support CLDC and CDC
– Enables support of MIDP 3 on CDC
Clarify spec and increase implementation consistency

33
MIDP 3.0 Functional Enhancements

● Concurrency (Multiple MIDlets at the same time)


● Shared libraries (LIBlets)
● Auto-start MIDlets
● Idle screen MIDlets
● Inter-MIDlet communication
● Record store interchange format
● User Interface improvements
● ...
34
Mobile Service Architecture v2

● Dynamic Environment
Download new APIs to the handset
Place custom middleware on handset
● Next revision of MSA 248
Supports both CLDC and CDC
Builds upon and requires MIDP 3.0
Adds multi-tasking and on-device service framework
Adds competitive user interface toolkit
Adds device segments: entry, standard, advanced
● No final release date yet

35
JavaFX

● JavaFX (http://javafx.com – integrated in NetBeans 6.5+)


New UI libraries (graphics, media, web services)
Consistent experience across mobile, desktop, browser, TV, etc
Plus: use any Java library in JavaFX
Integrated with Java Runtime
● JavaFX Script
Simple declarative language, easier to learn
e.g., for artists to change sprite animation, without needing
software developer
Advantage to JavaScript / ActionScript: integration with Java –
reuse any Java library

36
JavaFX Mobile

● Runs on Java ME (plus Android)


Mobile content with same tools as
Java FX
● Availability?
JavaFX Mobile Runtime needs to be
pre-installed on the phone
No phones released yet
Currently endorsed by:
SonyEricsson, LG
37
Blu-Ray Disc Java: BD-J

● Based on Java ME Personal Basis Profile & earlier Java TV


spec
GUI environment suitable for consumer electronics (no
keyboard / mouse)
Strong media support
● Applications?
Dynamic menu systems
Downloading additional content (subtitles, movie previews,
etc.)
Games and other bonus material

38
Internals

Java ME – Applications

39
Code  Application
Runtime
Source code (.java)
verification

Compile
Interpreter
(javac)
.jar-file
(MIDlet Suite) Runtime environment
.class-files (KVM)

Packaging
Preverification

.class-files

IDE
40
Preverification

● Verification: check the integrity of the byte code at


runtime
● Too much for mobile devices, therefore:
pre-verification at compile time:
Takes care of resource demanding checks
Simplifies runtime verification
Adds additional attributes to the .class file
(5 – 15% increase in size)

41
MIDlet Suite

MIDlet 1 MIDlet 2 MIDlet 3

MIDlet Suite (.jar-Archiv):


- Defines access rights
- Possibility to share data (Record Stores)
- Shared static variables

42
MIDlet-Suite

Preverified .class-
file(s)

Resources
(icons, graphics –
optional)

Information about
Manifest
.jar

.jad file
.jar-archive (Application
(MIDlet Suite) descriptor, optional)

43
Manifest

● Text file “MANIFEST.MF”


● Contains meta information

Manifest-Version: 1.0
MIDlet-Name: RealReplay
MIDlet-Description: RealReplay
MIDlet-Vendor: Mopius
MIDlet-Info-URL: http://www.mopius.com/
MIDlet-Version: 0.96.20
MIDlet-Icon: /res/icon.png
MIDlet-1:
RealReplay,/res/icon.png,com.mopius.realreplay.RealReplayMIDlet
MicroEdition-Profile: MIDP-2.0
MicroEdition-Configuration: CLDC-1.1

44
Application Descriptor (.jad)

● Information about .jar contents


● Allows to check compatibility before downloading .jar
MIDlet-Name: RealReplay
MIDlet-Description: RealReplay
MIDlet-Vendor: Mopius
MIDlet-Info-URL: http://www.mopius.com/
MIDlet-Version: 0.96.20
MIDlet-Icon: /res/icon.png
MIDlet-1:
RealReplay,/res/icon.png,com.mopius.realreplay.RealReplayMIDlet
MicroEdition-Profile: MIDP-2.0
MicroEdition-Configuration: CLDC-1.1
MIDlet-Jar-Size: 114185
Add. MIDlet-Jar-URL: http://realreplay.mopius.com/files/realreplay.jar

45
Signing

● Access to some telephone functionality (e.g. socket


connections, SMS) restricted: warning is displayed
every time
● Solution:
Sign the checksum of .jar in .jad-file with an own key
(certificate)
Own certificate is signed with root certificate of a
trusted certificate authority

46
Why OTA for Deployment?

● Some phones (Samsung, Sagem, BREW,...) do not support


installing MIDlets through the PC or Bluetooth
● Only alternative:
Download directly through mobile phone
 Over-the-Air (OTA) delivery

47
Over-the-Air
Mobile Device HTTP Web Server
AMS (Application
Notification
Management JAD-Server JAR-Server
Server
Software)

GET /midlet.jad

200 OK

GET /midlet.jar

200 OK

POST /install-notify (900 Success)

200 OK

48
Optimization – Obfuscation

● Original intention:
Make reverse engineering more difficult
Code more difficult to read after de-compilation
● Renames classes to “a.class, b.class, …”
● Removes unused methods, variables, classes
● Significant size reduction
Over-the-Air = expensive!
MIDlet size restrictions in many phones
Improves speed (less code to load / parse)
49
Obfuscation
Original archive Obfuscated
79,2 kB 42,9 kB = 45% smaller!

50
Developing for JavaME

● Highest priority: memory usage and speed


●  often very few classes, object orientation reduced to
a minimum, frequent use of static variables
● But: today’s phones have got more memory

Example:
Winter Sports
from Digiment
Open Source (GPL)

51
How to develop:

Tools

52
IDEs: Sun NetBeans

● NetBeans (+ Mobility Pack)

53
IDEs: NetBeans

● Very good integration for mobile projects:


Localisation
Conditional compilation
Packaging
UI-Designer, game builder, …
● Relatively high system requirements

54
IDEs: Eclipse Is integrated in

● Eclipse + Plugin: EclipseME / MTJ (official plug-in)

55
IDEs: Eclipse

● Very good IDE


● Helps a lot with programming errors

● ME integration through Eclipse ME is average


● Few Java ME specific tools / support – just pure
Java
56
Emulators

● Sun Java Wireless Toolkit for CLDC (2.5.2 / 3.0 EA)


Tools for compiling, packaging and executing
● Emulator:
Debugging
Error handling
Text output through console
Allows performance analysis
Simulates internet access and GPS
● Download:
http://java.sun.com/javame/downloads/index.jsp

57
Sun WTK

Sample application
of NetBeans in the
WTK emulator

58
Manufacturer-Specific Emulators

● Different Java ME implementations


●  Every device manufacturer has its own emulator:
Nokia:
www.forum.nokia.com/Resources_and_Information/Tools/IDEs/
Sony Ericsson SDK for the Java ME Platform
developer.sonyericsson.com/site/global/docstools/java/p_java.jsp
Samsung
innovator.samsungmobile.com/

Motorola
developer.motorola.com/docstools/sdks/

59
J2ME Polish

● Tools suite to address Java ME shortcomings:


Own UI classes for custom, graphical UI
Build system, creates adapted version for specific handsets
Allows porting Java ME to Android
● Licensing:
Free for GPL products
1 commercial app: €990
Unlimited commercial apps: €14,990
● http://www.j2mepolish.org/
60
Commands

Event-Handling

61
Events – The Big Picture

* Requires registering the MIDlet

62
Listener

● Implement the Listener-Interface to get informed:


CommandListener: commandAction()
Notification when e.g. a menu item has been selected
ItemCommandListener: commandAction()
Used for events for individual items
ItemStateListener: itemStateChanged()
When an UI element has been changed

63
Commands

● Command = semantic information about an action


( how can an action be executed?)
● But no actual implementation of the action!
● Contains:
Short label One of them will be displayed on the
screen / in the menu, depending on the
Long label (optional) available space

“Intention” of the command – e.g. for


Type special placement on the device
Priority For the order of commands, if more are
mapped to the same softkey. The lower
the priority, the more important it is.
65
Command-Types

Type Description
BACK Navigate to the previous screen (logically)
OK Standard positive answer
CANCEL Standard negative answer, e.g. used for OK & CANCEL
EXIT Exit the application
SCREEN Application specific command, e.g. “Upload”
HELP Request display of help text
ITEM Command is specific for items of the Screen or
for elements of a Choice component
STOP Stop currently running process / task

66
Implementation
Exit e.g. like in the
“Hello World”-
Exercise

● Class HelloWorldMIDlet:
… implements CommandListener

● Define new command (member variable):


private Command cmdExit;

● Create it in the constructor:


cmdExit = new Command(“Exit”, Command.EXIT, 1);
frmMain.addCommand(cmdExit);
frmMain.setCommandListener(this);

67
Command Handling

● Method defined in the base class CommandListener:

public void commandAction (Command c, Displayable d)


{ true: forces shutdown, you have to
free resources!
if (c == cmdExit) false: shtudown can be prevented by
{ the MIDlet if necessary.
... mainly important if the framework
destroyApp(true);
wants / has to close down the app.
notifyDestroyed();
} Inform the app. manager that our
MIDlet wants to be shut down.
}

68
Exit Softkey

69
2 Softkeys, 3 Commands?

● Commands in the menu – placement depends on the phone:


WTK 2.5 Nokia Nokia S60
Series 40

70
That’s it!

Thanks for your attention

71

You might also like