The Java Platform Micro Edition Java ME
description
Transcript of The Java Platform Micro Edition Java ME
11
The Java Platform Micro EditionJava ME
Dr. Miguel A. LabradorDepartment of Computer Science & Engineering
[email protected]://www.csee.usf.edu/~labrador
2Copyright© Dr. Miguel A. Labrador
2Copyright© Dr. Miguel A. Labrador
2
Outline
• The Java platform• The Java ME platform• The Connected Limited Device Configuration (CLDC) 1.1• The Mobile Information Device Profile (MIDP) 2.0• Optional packages
3Copyright© Dr. Miguel A. Labrador
3Copyright© Dr. Miguel A. Labrador
3
The Java Platform
Operating System
Java Virtual Machine
Java Enterprise Edition
(Java EE)Java Standard
Edition (Java SE)
Java Micro Edition
(Java ME)
TV set up boxes, cellular phones, smart phones, PDAs
PCs, laptops
Servers
4Copyright© Dr. Miguel A. Labrador
4Copyright© Dr. Miguel A. Labrador
4
The Java Platform
Source: Sun Microsystems white paper “Java 2 ME Building Blocks for Mobile Devices”
5Copyright© Dr. Miguel A. Labrador
5Copyright© Dr. Miguel A. Labrador
5
The Java Platform Micro Edition (Java ME)
• Java platform for mobile devices and embedded systems– Resource-constrained in terms of CPU, memory, energy– Smallest footprint and smallest VM
• Differentiates between different types of resource-constrained devices– Some with more resources, such as set up boxes, automobile
navigation systems– More constrained devices, such as cellular phones, PDAs, pagers
• Architecture has four layers– JVM that sits on top of the operating system– The configuration layer– The profile layer– Optional packages layer
6Copyright© Dr. Miguel A. Labrador
6Copyright© Dr. Miguel A. Labrador
6
The Java ME Platform
Operating System
Java Virtual Machine
Optional Packages
Connected Limited Device Configuration
(CLDC)
Connected Device Configuration
(CDC)
Mobile Information Device Profile (MIDP)
Foundation Profile
Personal Profile
Optional Packages
7Copyright© Dr. Miguel A. Labrador
7Copyright© Dr. Miguel A. Labrador
7
The Java ME Platform
Operating System
Java Virtual Machine
Optional Packages
Connected Limited Device Configuration
(CLDC)
Connected Device Configuration
(CDC)
Mobile Information Device Profile (MIDP)
Foundation Profile
Personal Profile
Optional Packages
More resource-
constrained devices
8Copyright© Dr. Miguel A. Labrador
8Copyright© Dr. Miguel A. Labrador
8
The CLDC 1.1
• Targets devices with 192KB of memory, 16-bit or 32-bit processors, low power consumption, intermittent connectivity and limited bandwidth– Cell phones, pagers, PDAs, and the like
• Contains core Java libraries (java.lang.*; java.utili.*) and APIs for input/output, security, and networking
• Java programming language and VM features• Libraries and APIs
9Copyright© Dr. Miguel A. Labrador
9Copyright© Dr. Miguel A. Labrador
9
Java Programming Language and VM features
• Floating point support– Float and Double
• Calendar, Date, Timezone, and Thread objects redesigned to be more Java SE-compliant
• JVM the same as the one used in Java SE, except:– No finalization of class instances
• Method Object.finalize() not included– Exemption and error handling limitations– User-defined class loaders are not supported– Thread groups not supported; only individual threads– Class file verification not supported
• Only offline preverification with stack maps
10Copyright© Dr. Miguel A. Labrador
10Copyright© Dr. Miguel A. Labrador
10
The Preverification Process
Source: Sun Microsystems white paper “Java 2 ME Building Blocks for Mobile Devices”
11Copyright© Dr. Miguel A. Labrador
11Copyright© Dr. Miguel A. Labrador
11
Libraries and APIs• For upward compatibility, CLDC 1.1 includes libraries that are a
subset of the standard libraries included in Java SE and EE platforms– System classes essential to the Java programming language
• Java.lang package: java.lang.Object, *.Class, *.Runtime, *.System, *.Thread, *.Runnable, *.String, *.StringBuffer, *.Throwable
– Data type classes• Java.lang.Boolean, *.Byte, *.Short, *.Integer, *.Long, *.Float, *.Double,
*.Character– Collection classes
• Java.util.Vector, *.Stack, *.Hastable, *.Enumeration, *.Random, *.Math– Input/Output classes
• Java.io.InputStream, *.OutputStream, *.ByteArrayInputStream, *.ByteArrayOutputStream, *.DataInput, *.DataOutput, *.DataInputStream, *.DataOutputStream, *.Reader, *.Writer, etc.
12Copyright© Dr. Miguel A. Labrador
12Copyright© Dr. Miguel A. Labrador
12
Libraries and APIs– Calendar and Time classes
• Java.util.Calendar, *.Date, *.TimeZone– Exception and Error classes
• Java.util.Exception, *.AruthmeticException, *.ArrayStoreException, *.NullPointerException, *.NumberFormatException, *.RuntimeException, *.SecurityException, others.
• Java.lang.Error, *.NoClassDefFoundError, *.OutOfMemoryError, *.VirtualMachineError
• CLDC also includes some specific classes– Described within the Generic Connection Framework (GCF)
• Provide minimum input/output and networking support needed by all devices while opening the door for extending these capabilities and implementing new ones as needed by specific devices
– Reduces footprint
13Copyright© Dr. Miguel A. Labrador
13Copyright© Dr. Miguel A. Labrador
13
Libraries and APIs
• GCF included in the javax.microedition.io package and implements six basic Connection APIs– InputConnection
• openInputStream and openDataInputStream methods– OutputConnection
• openOutputStream and openDataOutputStream methods– StreamConnection
• Combines InputConnection and OutputConnection interfaces– Two way communication
– ContentConnection• Sub-interface of the StreamConnection interface that provides basic
information contained in HTTP connections– StreamConnectionNotifier
• acceptAndOpen method to block client program and wait for connection
14Copyright© Dr. Miguel A. Labrador
14Copyright© Dr. Miguel A. Labrador
14
Libraries and APIs
– DatagramConnection• Implements several methods to handle input/output of datagrams
– Receive(), send(), getMaximunLength()• The GCF includes a general abstraction to handle all forms of
communications– Connector.open (“<protocol>:<address>;<parameters>”);
• Connector.open(http://www.csee.usf.edu);• Connector.open(“socket://192.168.0.2:2800”);• Connector.open(“comm:0;baudrate=4800”);• Connector.open(“datagram://192.168.0.2:2800”);
15Copyright© Dr. Miguel A. Labrador
15Copyright© Dr. Miguel A. Labrador
15
The MIDP 2.0
• If the CLDC is a contract between the device and the Java programming language, the MIDP is a contract between the Java programming language and the application developer
• MIDP is the profile defined for CLDC devices• Minimum set of APIs required to develop graphical and
networked applications for resource-constrained mobile devices or MIDlets– User Interface APIs, Game APIs, Networking APIs, Security APIs,
Sound APIs, Storage APIs• MIDlets and MIDlets development will be covered right after this
topic
16Copyright© Dr. Miguel A. Labrador
16Copyright© Dr. Miguel A. Labrador
16
Optional Packages
• The Java ME platform is very rich in additional packages– Mobile Media API (JSR 135)
• Access and control multimedia resources and files. The Sound API included in MIDP is a subset of this API
– Security and Trust Services API (JSR 177)– Session Initiation Protocol API (JSR 180)– Mobile 3D Graphics API (JSR 184)– Event Tracking API (JSR 190)– Wireless Messaging API (JSR 120)– Location API (JSR 293)– Java ME Web Services API (JSR 172)– Many others