Download final

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Aim: Study experiment on J2ME
Theory:
Introduction
Java Platform, Micro Edition (Java ME) provides a robust, flexible environment for
applications running on mobile and embedded devices: mobile phones, set-top boxes, Blu-ray
Disc players, digital media devices, M2M modules, printers and more.
J2ME (Java 2 Micro Edition) is an advanced technology in Java, developed with the help of
Java Community Process Program. J2ME is a reduced version of the Java API and Java
Virtual Machine that is designed to operate within the limited resources available in the
embedded computers and microcomputers.J2ME is targeted to developers of intelligent
wireless devices and small computing devices who need to incorporate cross-platform
functionality in their products. A key benefit of using J2ME is compatibility with all Javaenabled devices. Motorola, Nokia, Panasonic all have Java-enabled devices. A J2ME
application is a balance between local and server-side processing.
Architecture of J2ME
While connected consumer devices such as cell phones, pagers, personal organizers and TV
set-top boxes have many things in common, they are also extremely diverse in form,
function, and features. Information appliances tend to be special-purpose, limited-function
devices. To address this diversity, an essential requirement for the J2ME architecture is not
only small size but also modularity and customizability.
Fig: Architecture of J2ME
Generally, Architecture of J2ME define into four basic layer:1. Application Layer:
Application layer targeted at two product groups, are:a. Mobile, personal, and connected information devices such as Pagers, Mobile
phones etc.
b. Fixed, shared, and connected information devices such as Car-Navigation
Systems, Internet Appliances, Set-Top boxes etc.
2. Profile Layer:
Profiles layer based on a configuration and additional API’s for user interface,
persistent storage and factors necessary for developing wireless applications.
a. Mobile Information Device (MIDP) Profile:
MIDP is specification published for the use of Java, mobile devices, and
embedded system. It is a part of Java Micro Edition (Java ME) framework and
top of a Connected Limited Device Configuration (CLDC). It provides a
standard platform for small, resource-limited, and wireless-connected mobile
information devices. MIDP requires CLDC for implementation.
Specification of MIDP launch under the Java Community Process:

MIDP 1.0 (JSR 37) - Approved on September 19, 2000

MIDP 2.0 (JSR 118) - Approved on November 20, 2002

MIDP 3.0 (JSR 271) - Approved on December 9, 2009
Core application programming interfaces (APIs) of MIDP:

javax.microedition.io

javax.microedition.lcdui

javax.microedition.rms

javax.microedition.midlet
b. Personal Digital Assistance (PDAP) Profile:
PDAP is specifically designed for Palmtop or similar devices with limited
power, typical battery operated, user interface displays like a pointing device
and character input, with minimum of 512kb (and maximum 16MB) combined
ROM (read only memory) and RAM (random access memory) hardware.
c. Personal Profile:
Personal profile specification repacks the Personal Java APIs Environment to
provide J2ME specification for devices that need a high degree of Internet
connectivity. This profile builds on top of foundation profile.
d. Personal Basic Profile:
This profile is intended to provide basic Graphical User Interface (GUI)
capabilities to devices where the high-fidelity, feature-rich Personal Profile not
fully utilized or necessary means which running the CDC and Foundation
Profile.
e. Remote Method Invocation (RMI) Profile:
RMI profile also builds on top of Foundation profile and supports interapplication RMI over TCP/IP connections for applications written to the
Foundation Profile. It's provides the infrastructure to marshal objects as the
parameters and return values of remote method calls while the dynamic class
loading is utilized to make the marshalled objects available to a particular
JVM during a remote call. A special type of protocol - wire protocol JRMP
(Java Remote Method Protocol) is required for supported.Core Application
Programming Interface (APIs) of RMI –
i. java.rmi
f. Foundation Profile:
The Foundation profiles specified for devices that can support a rich
networked J2ME environment. It provides services for other device-specific
profiles (such as Personal profile and RMI profile) to be layered on top of it.
This profile specific design for CDC profiles that provide Graphical User
Interface (GUI), Data storage, and distribution of java networking.
3. Configuration Layer:
The configuration Layer is define the basic defines the basic run-time environment as
a set of core classes and a specific JVM that run on specific kind of device based on
memory constraints and processor power.
a. Connected Limited Device Configuration (CLCD):
CLDC is a framework for ME defines the basic set of APIs, library, and
virtual-machine features for resource-constrained devices like pager, mobile
phones, and mainstream Personal Digital Assistants (PDAs) and must be
implemented into applications. It provide a standard platform for developers
for developing some complex applications on embedded devices with limited
resource such as phones and pager by combined with one or more than one
Profiles. CLDC is built on “scale down” version of Java virtual Machine
(JVM) called KVM (Kilobytes Virtual Machine) for 16-bit or 32-bit device
with limited amounts of memory.
b. Connected Device Configuration (CDC):
CDC is a framework for Java ME defines the basic set of APIs, library, and
virtual-machine features for resource-constrained devices like pager, mobile
phones, and mainstream Personal Digital Assistants (PDAs) and must be
implemented into applications. It provide a standard platform for developers
for developing some complex application for embedded systems(from pager to
set-top boxes) by combined with one or more than one Profiles.It specifies a
full Java virtual Machine (JVM) called CVM (C Virtual Machine) and is used
for 32- bit architectures requiring more than 2 MB of memory.
4. J2ME Foundation Layer:
J2ME layer allow the flexibility of definition of APIs these are general purpose
library, core classes, and independent to a particular device family. An abstraction of
JSE network and I/O classes is designed for J2ME to make connection between
mobile devices and web servers (if possible). It is called Generic Connection
Framework (GCF) and used at the programming level.
Classes, Methods and Interfaces in J2ME
The common methods, packages, listeners, classes etc. used in the major programs are as
follows:
1. Packages :
The main packages used are “midlet“ and “lcdui“
a. javax.microedition.midlet: The MIDlet package defines Mobile Information
Device Profile applications and the interactions between the application and the
environment in which the application runs.
b. javax.microedition.lcdui: The UI API provides a set of features for
implementation of user interfaces for MIDP applications.
c. java.io: Provides classes for input and output through data streams.
d. java.lang: Provides classes that are fundamental to the Java programming
language.
e. java.util: Contains the collection classes, and the date and time facilities.
2. Classes:
The most important class which has to be extended by the user created class is MIDlet
class. With this the user can extend many other classes namely Canvas, Timer,
TimerTask, etc. The other classes which are mainly used are Display, Command,
Form, ChoiceGroup, Font, Image, Graphics etc.
3. Listeners:
a. CommandListener : This interface is used by applications which need to
receive high-level events from the implementation.
b. ItemStateListener: This interface is used by applications which need to receive
events that indicate changes in the internal state of the interactive items within a
Form screen.
c. Runnable:The Runnable interface should be implemented by any class whose
instances are intended to be executed by a thread. The class must define a
method of no arguments called run.
4. Methods of various Classes and Interfaces:
a. MIDlet
protected
abstract void
destroyApp(boolean unconditional)
Signals the MIDlet to terminate and enter the Destroyed
state.
Void
notifyDestroyed()
Used by aMIDlet to notify the application management
software that it has entered into the Destroyed state.
protected
abstract void
protected
abstract void
pauseApp()
Signals the MIDlet to enter the Paused state.
startApp()
Signals the MIDlet that it has entered the Active state.
b. Display
Void
callSerially(Runnable r)
Causes the Runnable object r to have its run() method called
later, serialized with the event stream, soon after completion
of the repaint cycle.
static Display
getDisplay(MIDlet m)
Gets the Display object that is unique to this MIDlet.
Void
setCurrent(Displayable nextDisplayable)
Requests that a different Displayable object be made visible
on the display.
c. Canvas
Int
getGameAction(int keyCode)
Gets the game action associated with the given key code of
the device.
Boolean
isDoubleBuffered()
Checks if the Canvas is double buffered by the
implementation.
protected
abstract void
Void
paint(Graphics g)
Renders the Canvas.
repaint()
Requests a repaint for the entire Canvas.
d. Choice
Int
append(String stringPart, Image imagePart)
Appends an element to the Choice.
Int
getSelectedFlags(boolean[] selectedArray_return)
Queries the state of a Choice and returns the state of all
elements in the boolean array selectedArray_return.
Int
getSelectedIndex()
Returns the index number of an element in the Choice that
is selected.
String
getString(int elementNum)
Gets the String part of the element referenced by
elementNum.
Boolean
isSelected(int elementNum)
Gets a boolean value indicating whether this element is
selected.
Void
setFont(int elementNum, Font font)
Sets the application's preferred font for rendering the
specified element of this Choice.
Int
size()
Gets the number of elements present.
e. ChoiceGroup
Int
getSelectedFlags(boolean[] selectedArray_return)
Queries the state of a ChoiceGroup and returns the state of
all elements in the boolean array selectedArray_return.
Int
getSelectedIndex()
Returns the index number of an element in the
ChoiceGroup that is selected.
String
getString(int elementNum)
Gets the String part of the element referenced by
elementNum.
Boolean
isSelected(int elementNum)
Gets a boolean value indicating whether this element is
selected.
Int
size()
Returns the number of elements in the ChoiceGroup.
f. CommandListener
Void
commandAction(Command c, Displayable d)
Indicates that a command event has occurred on
Displayable d.
g. ItemStateListener
Void
itemStateChanged(Item item)
Called when internal state of an Item has been changed by
the user.
h. Runnable
Void
run()
When an object implementing interface Runnable is used
to create a thread, starting the thread causes the object's run
method to be called in that separately executing thread.
i. TimeTask
Boolean
cancel()
Cancels this timer task.
abstract void
run()
The action to be performed by this timer task.
Long
scheduledExecutionTime()
Returns the scheduled execution time of the most recent
actual execution of this task.
j. Timer
Void
cancel()
Terminates this
scheduled tasks.
timer, discarding any currently
Void
schedule(TimerTask task, Date time)
Schedules the specified task for execution at the
specified time.
Void
schedule(TimerTask task, Date firstTime, long period)
Schedules the specified task for repeated fixed-delay
execution, beginning at the specified time.
Void
schedule(TimerTask task, long delay)
Schedules the specified task for execution after the
specified delay.
Void
schedule(TimerTask task, long delay, long period)
Schedules the specified task for repeated fixed-delay
execution, beginning after the specified delay.
Void
scheduleAtFixedRate(TimerTask task, Date firstTime,
long period)
Schedules the specified task for repeated fixed-rate
execution, beginning at the specified time.
Void
scheduleAtFixedRate(TimerTask task,
long delay,
long period)
Schedules the specified task for repeated fixed-rate
execution, beginning after the specified delay.
Conclusion: Hence we studied J2ME, it’s architecture and it’s common classes, methods and
interfaces.