Java on MIDs

Download Report

Transcript Java on MIDs

Programming of Handheld and Mobile
Devices
Lecture 10 Java for MIDs
Rob Pooley [email protected]
Programming Handheld and
Mobile devices
1
Java 2 Platform, Micro Edition (J2ME)
• The Java 2 Platform, Micro Edition (J2ME) provides a
flexible environment for applications running on
consumer devices, such as mobile phones, PDAs, and
TV set-top boxes, as well as a broad range of embedded
devices.
• J2ME includes Java virtual machines and a set of
standard Java APIs
• It includes flexible user interfaces, a robust security
model, a broad range of built-in network protocols, and
extensive support for networked and offline applications
Programming Handheld and
Mobile devices
2
The J2ME Architecture
• The J2ME architecture comprises a variety of
configurations, profiles, and optional packages that
implementers and developers can choose from
Programming Handheld and
Mobile devices
3
J2ME Configurations and Profiles
•
•
•
•
Even within J2ME one size does not fit all
Configurations: Minimum libraries and JVM
Profiles: libraries for specific devices or markets
J2ME configurations
– CLDC
– CDC
• J2ME profiles
•
MIDP
– Foundation, Bluetooth, Personal, ...
• Configurations and profiles defined by the Java
Community ProcessSM
Programming Handheld and
Mobile devices
4
Configurations
•
•
•
Configurations comprise
– a virtual machine
– a minimal set of class libraries.
They provide the base functionality for a particular
range of devices that share similar characteristics, such
as network connectivity and memory footprint.
Currently, there are two J2ME configurations:
– the Connected Limited Device Configuration (CLDC)
• Established and widely used
– the Connected Device Configuration (CDC)
• Next generation configuration
Programming Handheld and
Mobile devices
5
Profiles
• To provide a complete runtime environment for a specific
device category a configuration must be combined with a
profile
• This is a set of higher-level APIs that further define the
application life-cycle model, the user interface, and
access to device-specific properties.
• A profile supports a narrower category of devices within
the framework of a chosen configuration.
• A widely adopted example is to combine CLDC with the
Mobile Information Device Profile (MIDP) to provide a
complete Java application environment for cell phones
and other devices with similar capabilities
Programming Handheld and
Mobile devices
6
Optional Packages
• The J2ME platform can be extended by adding
various optional packages to a technology stack
that includes either CLDC or CDC and an
associated profile.
• Optional packages offer standard APIs for using
both existing and emerging technologies such
as database connectivity, wireless messaging,
multimedia, Bluetooth, and web services.
• Because optional packages are modular,
developers can avoid carrying the overhead of
unnecessary functionality by including only the
packages an application actually needs.
Programming Handheld and
Mobile devices
7
Programming Handheld and
Mobile devices
8
Mobile Information Device Profile
• The first J2ME profile
• Targets devices implementing CLDC
• Profile addresses:
– Display toolkit, user input methods
– Persistent data storage
– Messaging( SMS, email, etc), security and networking
over wireless network connection
Programming Handheld and
Mobile devices
9
Related Technologies:
Java Card™ Technology
• Specifies minimized subset of
Java technology for GSM SIM
cards, smart cards, Java rings,
and other extremely constrained
devices
•
Key benefits versus non-Java
smart cards
– Multiple applications per card
– Post-issuance updates to
apps on card
Programming Handheld and
Mobile devices
10
Related Technologies:
EmbeddedJava™ Technology
•
•
EmbeddedJava. technology is a program from Sun
supporting development of dedicated-function
embedded devices for a wide range of end uses
EmbeddedJava technology gives device manufacturers
the ability to:
– Configure the Java platform to leave out unneeded
classes and VM features
– Minimize resource requirements and cost for a
deeply-embedded device
– Optimize for devices with no GUI and intermittent
(at best) networking
– Keep APIs for their devices private
Programming Handheld and
Mobile devices
11
J2ME™: Connected Device Configuration
• Connected Device Configuration (CDC)
– Targeted for devices that have 2 MB or more total
available memory
– Memory dedicated to J2ME environment
– More than 2MB ROM/Flash
– More than 512 KB RAM
– Network connectivity
– Full Java 2 Virtual Machine specification
Programming Handheld and
Mobile devices
12
Example J2ME™ CDC Uses
•
•
•
•
•
•
•
Wireless communicators
High-end PDAs
TV set-top boxes
Gateways
Automotive entertainment and navigation systems
Telecomm/Networking Equipment
Industrial Controllers
Programming Handheld and
Mobile devices
13
What Is CVM?
• Basis for J2ME CDC and profiles
– Large VMs for desktops/servers don.t scale well to
devices
– Static and dynamic memory footprint too big
– Not embeddable, ROMable, not portable
– Implicit assumption of virtual memory
– Native stack use, address range reservation
– Implicit assumption of process model
• Global variables, .system threads.
Programming Handheld and
Mobile devices
14
CVM features
•
•
•
•
•
Good JVM features
Device friendliness.
Easily re-targetable
Narrow porting interface
Almost entirely in C (except
dynamic compiler)
• ~256KB with JNI, reflection,
verification,.
• CVM supports all Java 2 Platform,
version 1.3,
• VM features and libraries for
security, weak references, JNI, RMI
and JVMDI
• CVM allows devices to map Java
threads directly to native threads.
• Can run Java classes out of ROM
• Contains a precise memory system
with advanced Garbage Collection
features:
• Small average GC pause times
• Pluggable Garbage Collectors
• Full separation of VM from memory
system
Programming Handheld and
Mobile devices
15
J2ME Profiles
• Mobile Information Device Profile (MIDP)
– Profile for wireless devices implementing CLDC
• J2ME Foundation Profile
– Profile for non-GUI networked devices implementing
CDC
• J2ME Personal Basis, Personal, RMI Profiles
– Basic graphics, next generation PersonalJava
environment, and RMI support for CDC & Foundation
Profile based devices
Programming Handheld and
Mobile devices
16
CDC APIs
• 􀀀 Defines minimum set of APIs for Java VM support
– java.lang VM system classes (Object, Thread, etc.)
– java.util.Underlying utilities
– java.net.UDP Datagram and File URL
– java.io.File
– java.text.I18n support for Java VM error messages
– java.security.Fine grain security and encryption for
object serialization
Programming Handheld and
Mobile devices
17
CVM Sizes Today
• CVM only
– Static ROM + RAM req.= 258 KB
• Natives only
– Static ROM + RAM req.= 124 KB
• Porting layer only
– Static ROM + RAM req.= 28 KB
• CVM+natives+porting_layer
– Static ROM + RAM req.= 410 KB
Programming Handheld and
Mobile devices
18
Foundation Profile APIs
• Defines core set of Java platform functionality
– No GUI
– Subset of JDK 1.3
• Completes full functionality from CDC
– java.lang.Rounds out full java.lang.*(Compiler,
UnknownError)
– java.util.Adds full zip support, Timer, etc.
– java.net.Adds TCP Socket and HTTP
– java.io.Rounds out full java.io.* (Readers and Writers)
– java.text.Full I18n (Annotation, Collator, Iterators, etc.)
– java.security.Adds Code Signing and Certificates
Programming Handheld and
Mobile devices
19
CVM Sizes with Foundation Profile APIs
• CDC Java libraries (ROMized)
– Static ROM + RAM req.= 1011 KB
• Foundation Java libraries (ROMized)
– Static ROM + RAM req.= 1564 KB
• CDC TOTAL (CVM+natives+porting+libraries)
– Static ROM + RAM req.= 1421 KB
• Java libraries + natives for Foundation Profile
– Static ROM + RAM req = 553 KB
• Foundation TOTAL (CVM+natives+porting+libraries)
– Static ROM + RAM req.= 1974 KB
Programming Handheld and
Mobile devices
20