ppt - Computer Science and Engineering

advertisement
The Java Platform Micro Edition
Java ME
Dr. Miguel A. Labrador
Department of Computer Science & Engineering
labrador@csee.usf.edu
http://www.csee.usf.edu/~labrador
1
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
2
Copyright© Dr. Miguel A. Labrador
2
The Java Platform
Servers
PCs, laptops
Java Enterprise
Edition
(Java EE)
Java Standard
Edition
(Java SE)
TV set up
boxes, cellular
phones, smart
phones, PDAs
Java Micro
Edition
(Java ME)
Java Virtual Machine
Operating System
3
Copyright© Dr. Miguel A. Labrador
3
The Java Platform
4
Source: Sun Microsystems white paper “Java 2 ME Building Blocks for Mobile Devices”
Copyright© Dr. Miguel A. Labrador
4
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
5
Copyright© Dr. Miguel A. Labrador
5
The Java ME Platform
Optional Packages
Personal Profile
Optional Packages
Foundation Profile
Mobile Information Device
Profile
(MIDP)
Connected Device
Configuration
(CDC)
Connected Limited Device
Configuration
(CLDC)
Java Virtual Machine
Operating System
6
Copyright© Dr. Miguel A. Labrador
6
The Java ME Platform
More
resourceconstrained
devices
Optional Packages
Personal Profile
Optional Packages
Foundation Profile
Mobile Information Device
Profile
(MIDP)
Connected Device
Configuration
(CDC)
Connected Limited Device
Configuration
(CLDC)
Java Virtual Machine
Operating System
7
Copyright© Dr. Miguel A. Labrador
7
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
8
Copyright© Dr. Miguel A. Labrador
8
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
9
Copyright© Dr. Miguel A. Labrador
9
The Preverification Process
10
Source: Sun Microsystems white paper “Java 2 ME Building Blocks for Mobile Devices”
Copyright© Dr. Miguel A. Labrador
10
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.
11
Copyright© Dr. Miguel A. Labrador
11
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
12
Copyright© Dr. Miguel A. Labrador
12
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
13
Copyright© Dr. Miguel A. Labrador
13
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”);
14
Copyright© Dr. Miguel A. Labrador
14
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
15
Copyright© Dr. Miguel A. Labrador
15
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
16
Copyright© Dr. Miguel A. Labrador
16
Download