Vous êtes sur la page 1sur 27

Programming Language

Object-oriented programming

Object-oriented programming (OOP) is a programming paradigm using "objects" – data


structures consisting of data fields and methods together with their interactions – to
design applications and computer programs. Programming techniques may include
features such as data abstraction, encapsulation, messaging, modularity, polymorphism,
and inheritance. Many modern programming languages now support OOP.

By contrast, the object-oriented approach encourages the programmer to place data where
it is not directly accessible by the rest of the program. Instead the data is accessed by
calling specially written functions, commonly called methods, which are either bundled
in with the data or inherited from "class objects" and act as the intermediaries for
retrieving or modifying those data. The programming construct that combines data with a
set of methods for accessing and managing those data is called an object.

An object-oriented program will usually contain different types of objects, each type
corresponding to a particular kind of complex data to be managed or perhaps to a real-
world object or concept such as a bank account, a hockey player, or a bulldozer. A
program might well contain multiple copies of each type of object, one for each of the
real-world objects the program is dealing with. For instance, there could be one bank
account object for each real-world account at a particular bank. Each copy of the bank
account object would be alike in the methods it offers for manipulating or reading its
data, but the data inside each object would differ reflecting the different history of each
account.

Objects can be thought of as wrapping their data within a set of functions designed to
ensure that the data are used appropriately, and to assist in that use. The object's methods
will typically include checks and safeguards that are specific to the types of data the
object contains. An object can also offer simple-to-use, standardized methods for
performing particular operations on its data, while concealing the specifics of how those
tasks are accomplished. In this way alterations can be made to the internal structure or
methods of an object without requiring that the rest of the program be modified. This
approach can also be used to offer standardized methods across different types of objects.
As an example, several different types of objects might offer print methods. Each type of
object might implement that print method in a different way, reflecting the different kinds
of data each contains, but all the different print methods might be called in the same
standardized manner from elsewhere in the program. These features become especially
useful when more than one programmer is contributing code to a project or when the goal
is to reuse code between projects

Java language
Java is a programming language originally developed by James Gosling at Sun
Microsystem. The language derives much of its syntax from C and C++ but has a simpler
object model and fewer low-level facilities. Java applications are typically compiled to
byte code (class file) that can run on any Java Virtual Machine (JVM) regardless of
computer architecture.
Java is a general-purpose, concurrent, class-based, object-oriented language that is
specifically designed to have as few implementation dependencies as possible. Java is
currently one of the most popular programming languages in use, and is widely used
from application software to web applications.

Principles

There were five primary goals in the creation of the Java language:

1. It should be "simple, object oriented and familiar".


2. It should be "robust and secure".
3. It should have "an architecture-neutral and portable environment".
4. It should execute with "high performance".
5. It should be "interpreted, threaded, and dynamic".
Java Virtual Machine

A Java Virtual Machine (JVM) enables a set of computer software


programs and data structures to use a virtual machine model for the execution of
other computer programs and scripts. The model used by a JVM accepts a form of
computer intermediate language commonly referred to as Java bytecode. This
language conceptually represents the instruction set of a stack-oriented, capability
architecture. A JVM can also execute bytecode compiled from programming
languages other than Java. "write once, run anywhere".

Java Development Kit

The Java Development Kit (JDK) is a Sun Microsystems product aimed at Java
developers. Since the introduction of Java, it has been by far the most widely used Java

JDK contents

The JDK has as its primary components a collection of programming tools, including:

• java – the loader for Java applications. This tool is an interpreter and can interpret
the class files generated by the javac compiler. Now a single launcher is used for
both development and deployment. The old deployment launcher, jre, no longer
comes with Sun JDK.
• javac – the compiler, which converts source code into Java bytecode
• jar – the archiver, which packages related class libraries into a single JAR file.
This tool also helps manage JAR files.
• javadoc – the documentation generator, which automatically generates
documentation from source code comments
• jdb – the debugger
• jps – the process status tool, which displays process information for current Java
processes
• javap – the class file disassembler
• appletviewer – this tool can be used to run and debug Java applets without a web
browser

Execution environment

Java's execution environment is termed the Java Runtime Environment, or JRE.

Programs intended to run on a JVM must be compiled into a standardized portable binary
format, which typically comes in the form of .class files. A program may consist of many
classes in different files. For easier distribution of large programs, multiple class files
may be packaged together in a .jar file (short for Java archive).

The JVM runtime executes .class or .jar files, emulating the JVM instruction set by
interpreting it, or using a just-in-time compiler (JIT)
JIT compiling, not interpreting, is used in most JVMs today to achieve greater speed.
There are also ahead-of-time compilers that enable developers to precompile class files
into native code for particular platforms.

Class libraries

Java libraries are the compiled byte codes of source code developed by the JRE
implementer to support application development in Java. Examples of these libraries are:
The core libraries, which include:

1. Collection libraries that implement data structures such as lists,


dictionaries, trees, sets, queues and double-ended queue, or stacks
2. XML Processing (Parsing, Transforming, Validating) librarie
3. Security
4. Internationalization and localization libraries

Syntax:
The syntax of Java is largely derived from C++. Unlike C++, which combines the
syntax for structured, generic, and object-oriented programming, Java was built almost
exclusively as an object-oriented language. All code is written inside a class, and
everything is an object, with the exception of the primitive data types (integers, floating-
point numbers, boolean values, and characters), which are not classes for performance
reasons

What is Java Servlets?

Servlets are server side components that provide a powerful mechanism for developing
server side programs. Servlets provide component-based, platform-independent methods
for building Web-based applications, without the performance limitations of CGI
programs. Unlike proprietary server extension mechanisms (such as the Netscape Server
API or Apache modules), servlets are server as well as platform-independent. This leaves
you free to select a "best of breed" strategy for your servers, platforms, and tools. Using
servlets web developers can create fast and efficient server side application which can run
on any servlets enabled web server. Servlets run entirely inside the Java Virtual Machine.
Since the Servlets runs at server side so it does not checks the browser for compatibility.
Servlets can access the entire family of Java APIs, including the JDBC API to access
enterprise databases. Servlets can also access a library of HTTP-specific calls; receive all
the benefits of the mature java language including portability, performance, reusability,
and crash protection. Today servlets are the popular choice for building interactive web
applications. Third-party servlets containers are available for Apache Web Server,
Microsoft IIS, and others. Servlets containers are usually the components of web and
application servers, such as BEA Web Logic Application Server, IBM Web Sphere, Sun
Java System Web Server, Sun Java System Application Server and others.

Servlets are not designed for specific protocols. It is different thing that they are most
commonly used with the HTTP protocols Servlets uses the classes in the java packages
javax.servlet and javax.servlet.http. Servlets provides a way of creating the sophisticated
server side extensions in a server as they follow the standard framework and use the
highly portable java language
The fundamental characteristics of Servlets are as follows:

 Servlets are created and managed at run time by the Servlets engine, that runs
inside the Java server.
 The input data on which servlets operate is encapsulated in an object called the
request object. A Servlets response to a query is encapsulated in an object called the
response object.
 Servlets call Ebbs to perform business logic functions. Servlets call JSPs to
perform page layout functions.
 Servlets control user sessions in order to provide some persistence of user
information between interactions.
 Servlets can be a part of a particular application, or they can reside separately in
order to be available to multiple applications. The latter type are said to be members
of the generic ("Default") application.
 Servlets can be dynamically reloaded while the server is running.
 Servlets are addressable as URLs. The buttons on your application's pages usually
point to servlets. Servlets can also call other servlets.

The Open Database Connectivity (ODBC):

The Open Database Connectivity (ODBC) standard is a common application


programming interface for accessing data files. In other words, ODBC allows you to
move data back and forth easily between ODBC compliant applications. So, for example,
you can easily extract data from a Microsoft Excel spreadsheet or Paradox database
using SAS or SPSS without having to go through any tedious translation procedure. With
ODBC, all you have to do is specify the type of file you are accessing and the data you
want, and the ODBC driver will do the rest of the work.

ODBC Components:

ODBC is composed of four main components:


1. the client application,
2. ODBC driver manager,
3. ODBC drivers,
4. ODBC data source.

The client application in this discussion will be either SAS or SPSS, and is the
computer package that you will be using for your data manipulation or analysis. The
ODBC driver manager is a program used to manage the links between the various
applications and to configure data transfer settings. The ODBC drivers serve as the link
between the client and ODBC data, and must be installed for each application. These
drivers might also be composed of a network component that could be used to transfer
data from a remote server. Finally, an ODBC data source is a user-generated
configuration of a particular data file created using the ODBC driver manager for access
by client applications.

Use of ODBC:

ODBC can be used as a translation engine, facilitating the movement of data


between different applications with dissimilar file structures. While most applications
have some sort of import file command that performs much the same task as ODBC in
this kind of situation, ODBC typically provides a more versatile and in some cases easier
to use interface for transferring data between programs. SAS and SPSS can read a variety
of different file types (e.g. Lotus, Excel, dBase, etc.) without having to resort to using
ODBC. With ODBC serving as the translation engine, however, you can easily access
data files from any application and any version -- as long as the proper ODBC drivers are
installed.

ODBC Driver Limitations:

ODBC is based on SQL and as such, even if an operation is supported by


Superbase, that does not mean that it is supported by SQL. One major difference
between Superbase and the ODBC driver is that Superbase allows updating of
files which do not possess a unique key. ODBC does not support this and as such
will return an error 901 if an attempt is made to update a record in a file that does
not have at least one unique index.

Java Database connectivity(JDBC)

The JDBC API defines the Java interfaces and classes that programmers use to
connect to databases and send queries. A JDBC driver implements these interfaces and
classes for a particular DBMS vendor.
A Java program that uses the JDBC API loads the specified driver for a
particular DBMS before it actually connects to a database. The JDBC DriverManager
class then sends all JDBC API calls to the loaded driver.

JDBC Driver:
This topic defines the Java(TM) Database Connectivity (JDBC) driver types.
Driver types are used to categorize the technology used to connect to the database. A
JDBC driver vendor uses these types to describe how their product operates. Some
JDBC driver types are better suited for some applications than others.

Types of JDBC drivers:


This topic defines the Java(TM) Database Connectivity (JDBC) driver types.
Driver types are used to categorize the technology used to connect to the database. A
JDBC driver vendor uses these types to describe how their product operates. Some JDBC
driver types are better suited for some applications than others.
There are four types of JDBC drivers known as:

• JDBC-ODBC bridge plus ODBC driver, also called Type 1.


• Native-API, partly Java driver, also called Type 2.
• JDBC-Net, pure Java driver, also called Type 3.
• Native-protocol, pure Java driver, also called Type 4.

JDBC APIs
As you knew that JDBC API is a collection of java classes and Interfaces. java.sql.*;
and javax.sql.*; package contains the collection of JDBC APIs.
Following are the important classes and interfaces of java.sql.*; package.

DriverManager – It is very important class, which defines object to open a


connection to the database. It is also used to load JDBC driver in memory.

Connection – The java database application manages the connection to a


database. It represents a collection to the database. It is also used for creating
Statement, PreparedStatement and CollableStatement Objects.

Statement – Statement object is used to retrieve a result into ResultSet. It


represents a static SQL statement.

PreparedStatemet- It represents a precompiled SQL statement. It is alternative to


Statement.
CallableStatement- It represents a stored procedures execute stored them in
RDBMS.

ResultSet –It represents a set of results generated by SELECT Sql statement.

SQLException- JDBC provides SQLException class, which contains the


database access errors. It is a core JDBC class that provides database access
errors. Many JDBC API’s throws SQLException.

Use of JDBC:

JDBC helps the java developers to develop a data access application without having
knowledge of complex API’s of different database vendors. You only need to learn JDBC
to develop java Data Access Application to different database to different database
applications using different JDBC drivers.

mDatabase:

e A database (DB) is an organized collection of data for one or more uses, typically in
digital form. The data are typically organized to model a certain aspect of reality, an
application (e.g., the manufacturing processes in the company X), in a way that the views
shown by such a collection can help to follow and manage these aspects/application. The
term "database" refers both to the way its users view it, and to the logical and physical
materialization of its data, content, in files, computer memory, and computer data
storage. This definition is very general, and many systems' data collections rightfully
comply with it. However, usually the term DB means a collection of data which is
maintained by a general-purpose Database management system (DBMS). A general-
purpose DBMS is typically a complex software system that meets many usage
requirement, and the DBs that it maintains are accordingly complex.
A DB is different from a DBMS which is a software system that allows to store and
change the DB, as well as retrieve information from it. Such information is computed (by
the DBMS) from the DB's stored data. The structure of such a DB is too complex to be
handled without its DBMS, and any attempt otherwise is very likely to result in the DB's
corruption. A specific DB with specific data is the vehicle to manage a specific
application, while its respective DBMS is the tool to use and maintain the DB. DBMSs
are packaged as computer software products. Each DBMS type can support a DB type
which is specific to that DBMS, as designed by the DBMS manufacturer/developer(s).
Several popular general-purpose DBMS types exist, like the Oracle DBMS, Access and
SQL Server of Microsoft, DB2 of IBM and the Open source DBMS MySQL.

vi A Database Management System (DBMS) is a software system for archiving files


within a structured database such that previously saved versions are traceable and may be
recovered in a systematic way. It is a set of computer programs that controls the creation,
maintenance, and the use of a database. It allows organizations to place control of
database development in the hands of database administrators (DBAs) and other
specialists. A DBMS is a system software package that helps the use of integrated
collection of data records and files known as databases. It allows different user
application programs to easily access the same database. DBMSs may use any of a
variety of database models, such as the network model or relational model. In large
systems, a DBMS allows users and other software to store and retrieve data in a
structured way. Instead of having to write computer programs to extract information, user
can ask simple questions in a query language.

Microsoft Access 2003 is a powerful, yet easy to learn, relational database application for
Microsoft Windows. This tutorial is designed for users who are new or only have little
experience using Access 2003. It introduces fundamental database concepts and
operations and illustrates how they are performed in Microsoft Access 2003. This tutorial
does not cover all of the features and functions of Microsoft Access 2003; emphasis will
be on basic and frequently-used features, such as the creation of tables and queries, or
importing spreadsheet into Access.
Please be aware that Microsoft Access is only available for Windows users; Mac users
may want to seek out a FileMaker Pro Tutorial.
Objectives
By using this tutorial, you will learn to perform the following operations in Access 2003:
• Launch Access and identify the parts of the screen.
• Define fields and field properties constructing table structures.
• Enter and edit records in a table.
• Find, sort data.
• Design custom queries to display data.
• Import and export data between Excel and Access.

Definations
These words are used often in Access so you will want to become familiar with them
before using the program and this tutorial.
Relational Database: in relational databases such as Access, data is stored in tables made
up of one or more fields (Access calls a column a field). The data stored in each : column
must be of a single data type such as Character, Number or Date. A collection of values
from each column of a table is called a record or a row in the table.
Different tables can have the same column in common. This feature is used to explicitly
specify a relationship between two tables. Values appearing in column A in one table are
shared with another table
Table: tables are the main units of data storage in a database. A table is a collection of
data about a specific topic; it is made up of one of more fields.
Field: a field is a column in a table and defines a data type for a set of values in a table.
For example, a mailing list table might include fields for first name, last name, address,
city, state, zip code, and telephone number.
Record: a record in a row in a table and is a set of values defined by fields. In a mailing
list table, each record would contain the data for one person as specified by the
intersecting fields.
Data type: data types are the properties of each field. A field only has one data type, such
as Character, Number or Date.
Primary Key: a primary key is a value that can be used to identify a unique record in a
table.
Design View: it provides the tools for creating fields in a table.

Datasheet View: it allows you to update, edit, and delete in formation from a table.

Database Components
An Access database consists of several different components. Each component listed is
called an object.
Listed below are the names and descriptions of the different objects you can use in
Access. This tutorial will focus on the first two objects: tables and queries.
Tables
Tables are where the actual data is defined and entered. Tables consist of
records (rows) and fields (columns).
Queries
Queries are basically questions about the data in a database. A query consists of
specifications indicating which fields, records, and summaries you want to see from a
database. Queries allow you to extract data based on the criteria you define.
Forms
Forms are designed to ease the data entry process. For example, you can create a data
entry form that looks exactly like a paper form. People generally prefer to enter data into
a well-designed form, rather than a table.
Reports
When you want to print records from your database, design a report. Access even has a
wizard to help produce mailing labels.
Pages
A data access page is a special type of Web page designed for viewing and working with
data from the Internet or an intranet. This data is stored in a Microsoft Access database or
a Microsoft SQL Server database.
Macros
A macro is a set of one or more actions that each performs a particular operation, such as
opening a form or printing a report. Macros can help you automate common tasks. For
example, you can run a macro that prints a report when a user clicks a command button.
Modules
A module is a collection of Visual Basic for Applications declarations and procedures
that are stored together as a unit.

Software Testing:

Software testing is any activity aimed at evaluating an attribute or capability of a


program or system and determining that it meets its required results. Although crucial to
software quality and widely deployed by programmers and testers, software testing still
remains an art, due to limited understanding of the principles of software. The difficulty
in software testing stems from the complexity of software: we can not completely test a
program with moderate complexity. Testing is more than just debugging. The purpose of
testing can be quality assurance, verification and validation, or reliability estimation.
Testing can be used as a generic metric as well. Correctness testing and reliability testing
are two major areas of testing. Software testing is a trade-off between budget, time and
quality.

Software Testing Types:

ACCEPTANCE TESTING
Testing to verify a product meets customer specified requirements. A customer
usually does this type of testing on a product that is developed externally.
BLACK BOX TESTING
Testing without knowledge of the internal workings of the item being tested.
Tests are usually functional.
COMPATIBILITY TESTING
Testing to ensure compatibility of an application or Web site with different
browsers, OSs, and hardware platforms. Compatibility testing can be performed
manually or can be driven by an automated functional or regression test suite.
CONFORMANCE TESTING
Verifying implementation conformance to industry standards. Producing tests for
the behavior of an implementation to be sure it provides the portability,
interoperability, and/or compatibility a standard defines.
FUNCTIONAL TESTING
Validating an application or Web site conforms to its specifications and correctly
performs all its required functions. This entails a series of tests which perform a
feature by feature validation of behavior, using a wide range of normal and
erroneous input data. This can involve testing of the product's user interface,
APIs, database management, security, installation, networking, etcF testing can be
performed on an automated or manual basis using black box or white box
methodologies.
INTEGRATION TESTING
Testing in which modules are combined and tested as a group. Modules are
typically code modules, individual applications, client and server applications on
a network, etc. Integration Testing follows unit testing and precedes system
testing.
LOAD TESTING
Load testing is a generic term covering Performance Testing and Stress Testing.
PERFORMANCE TESTING
Performance testing can be applied to understand your application or WWW site's
scalability, or to benchmark the performance in an environment of third party
products such as servers and middleware for potential purchase. This sort of
testing is particularly useful to identify performance bottlenecks in high use
applications. Performance testing generally involves an automated test suite as
this allows easy simulation of a variety of normal, peak, and exceptional load
conditions.
REGRESSION TESTING
Similar in scope to a functional test, a regression test allows a consistent,
repeatable validation of each new release of a product or Web site. Such testing
ensures reported product defects have been corrected for each new release and
that no new quality problems were introduced in the maintenance process.
Though regression testing can be performed manually an automated test suite is
often used to reduce the time and resources needed to perform the required
testing.
SMOKE TESTING
A quick-and-dirty test that the major functions of a piece of software work
without bothering with finer details. Originated in the hardware testing practice of
turning on a new piece of hardware for the first time and considering it a success
if it does not catch on fire.
STRESS TESTING
Testing conducted to evaluate a system or component at or beyond the limits of its
specified requirements to determine the load under which it fails and how. A
graceful degradation under load leading to non-catastrophic failure is the desired
result. Often Stress Testing is performed using the same process as Performance
Testing but employing a very high level of simulated load.
SYSTEM TESTING
Testing conducted on a complete, integrated system to evaluate the system's
compliance with its specified requirements. System testing falls within the scope
of black box testing, and as such, should require no knowledge of the inner design
of the code or logic.
UNIT TESTING
Functional and reliability testing in an Engineering environment. Producing tests
for the behavior of components of a product to ensure their correct behavior prior
to system integration.
WHITE BOX TESTING
Testing based on an analysis of internal workings and structure of a piece of
software. Includes techniques such as Branch Testing and Path Testing. Also
known as Structural Testing and Glass Box Testing.
History [1e phones with support for

Introduction to J2ME:

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 that need to incorporate cross-platform functionality in their products. A key
benefit of using J2ME is compatibility with all Java-enabled devices. Motorola, Nokia,
Panasonic all have Java-enabled devices. A J2ME application is a balance between local
and server-side processing.

J2ME versus J2SE versus J2EE


This graphic depicts the devices that support J2ME applications and illustrates where
J2ME fits into the Java platform:
J2ME Architecture

There are 5 layers in J2ME Architecture. Those are:

• MIDP (Topmost Layer): Which contains Java APIs for user network connections,
persistence storage, and the user interface? It also has access to CLDC libraries
and MIDP libraries.
• J2ME API’s(Profiles): Which consists of the minimum set
of application programming interfaces for the small computing device
• Configurations: Which handles interactions between the profile and the JVM?
• JVM
• Operating System (Bottom Layer).
The J2ME architecture is intended to be modular and scalable so that it can support
the kinds of flexible deployment demanded by the consumer and embedded markets. To
enable this, the J2ME environment provides a range of Java Virtual Machine
technologies, each optimized for the different processor types and memory footprints
commonly found in the consumer and embedded marketplace.

For low-end, resource-limited consumer products, the J2ME environment supports


minimal configurations of the Java Virtual Machine and Java libraries that embody just
the essential capabilities of each kind of device. As device manufacturers develop new
features in their devices or service providers develop new and exciting applications, these
minimal configurations can be expanded with additional libraries that address the needs
of a particular market segment. To support this kind of customizability and extensibility,
three essential concepts are
defined by the J2ME architecture:

• Configuration. A J2ME configuration defines a minimum platform for a “horizontal”


category or grouping of devices, each with similar requirements on total memory budget
and processing power. A configuration defines the Java language and virtual machine
features and minimum class libraries that a device manufacturer or a content provider can
expect to be available on all devices of the same category.

• Profile. A J2ME profile is layered on top of (and thus extends) a configuration. A


profile addresses the specific demands of a certain “vertical” market segment or device
family. The main goal of a profile is to guarantee interoperability within a certain vertical
device family or domain by defining a standard Java platform for that market. Profiles
typically include class libraries that are far more domain-specific than the class libraries
provided in a configuration. One device can support multiple profiles.

• Optional package. Some APIs are applicable to a large number of devices and device
families. A J2ME optional package is a set of APIs that is layered on top of (and thus
extends) a profile. An optional package typically contains functionality that is
independent of any particular vertical market segment or device family. The main goal of
an optional package is to allow the definition
of APIs that can be added flexibly on top of a number of different profiles. One device
can support multiple optional packages.

Configurations, profiles, and optional packages are discussed in more detail below.
Configurations, profiles, and optional packages use the capabilities of the Java Virtual
Machine (JVM), which is considered to be part of the configuration.
The virtual machine usually runs on top of a host operating system that is part of the
system software of the target device. The high-level relationship between the different
software layers—the JVM, configuration, profiles, optional packages, and the host
operating system—is illustrated in Figure 2.2.
Figure 2.2 Software layers in a J2ME device
J2ME configurations, profiles, and optional packages are defined through industry
collaboration using the Java Community Process (JCP). For further information on the
Java Community Process, refer to the Java Community Process web site.
The Connected, Limited Device
Configuration (CLDC)
CLDC is the specification for a “class” of Java virtual machines that can
run on the categories of devices targeted by CLDC and support the profiles
layered on top of CLDC. The KVM is a particular implementation (currently the
one and only Sun reference implementation) of a Java virtual machine meeting
the CLDC specifications. Therefore, no discussion of KVM can be complete
without an understanding of the CLDC requirements. This chapter briefly
describes some of the CLDC specifications that affect the KVM.
CLDC Goals

• To define a standard Java platform for small, resource-constrained,


connected devices.
• To allow dynamic delivery of Java applications and content to those devices.
• To enable 3rd party application developers to easily create applications and
content that can be deployed to those devices.
CLDC Requirements
• To run on a wide variety of small devices ranging from wireless
communication devices such as cellular telephones and two-way pagers to
personal organizers, point-of-sale terminals and even home appliances.
• To make minimal assumptions about the native system software available in
CLDC devices.
• To define a minimum complement or the “lowest common denominator” of
Java technology applicable to a wide variety of mobile devices.
• To guarantee portability and interoperability of profile-level code between
the various kinds of mobile (CLDC) devices.
The entire CLDC implementation (static size of the virtual machine + libraries)
should fit in less than 128 kilobytes. The CLDC Specification assumes that
applications can be run in as little as 32 kilobytes of Java heap space.
CLDC Scope

The CLDC configuration addresses the following areas:


• Java language and virtual machine features
• Core Java libraries (java.lang.*, java.util.*)
• Input/output
• Networking
• Security
• Internationalization
The CLDC configuration does not address the following areas. These features
are addressed by profiles implemented on top of the CLDC:
• Application life-cycle management (application installation, launching,
deletion)
• User interface
• Event handling
• High-level application model (the interaction between the user and the application)

Introduction to the KVM

The KVM (also known as the K Virtual Machine) is a compact, portable Java
virtual machine intended for small, resource-constrained devices such as
cellular phones, pagers, personal organizers, mobile Internet devices, point-ofsale
terminals, home appliances, and so forth.
The high-level design goal for the KVM was to create the smallest possible
“complete” Java virtual machine that would maintain all the central aspects of
the Java programming language, and that would nevertheless run in a
resource-constrained device with only a few tens or hundreds of kilobytes of
available memory (hence the name K, for kilobytes). More specifically, the
KVM is designed to be:
• Small, with a static memory footprint of the virtual machine core in the
range 40 kilobytes to 80 kilobytes (depending on the target platform and
compilation options).
• Clean and highly portable.
• Modular and customizable.
• As “complete” and “fast” as possible without sacrificing the other design goals.
The KVM is implemented in the C programming language, so it can easily be
ported onto various platforms for which a C compiler is available. The virtual
machine has been built around a straightforward bytecode interpreter with
various compile-time flags and options to aid porting efforts and improve space
optimization.

Porting KVM

The majority of KVM source code is common to all implementations. The


relatively small amount of machine-dependent and/or platform-specific code
is isolated to small number of files. New or modified versions of these files
must be created for each port.
A relatively small number of well-specified runtime functions must be
implemented in order to provide the necessary interface between KVM and the
underlying native operating environment for such operations as:
• Initializations
• Finalizations (clean-up)
• Heap allocation/deallocation
• Fatal error reporting
• Event handling
• Current time

J2ME Configurations and Profiles


Serving the information appliance market calls for a large measure of flexibility
in how computing technology and applications are deployed. This flexibility is
required because of
1. the large range of existing device types and hardware configurations,
2. constantly improving device technology,
3. the diverse range of existing applications and features, and
4. the need for applications and capabilities to change and grow in order to accommodate
the future needs of consumer.
Midlets

A MIDlet is a J2ME application which operates on an MIDP. A MIDlet is


defined with at least a single class that is derived from the javax.microedition.midlet.
MIDlet abstract class. Common programming is grouping related MIDlets into a MIDlet
suite, which is contained within the same package and implemented simultaneously. All
MIDlets within a MIDlet suite are considered a group and must be installed and
uninstalled as a group. MIDlets from the same MIDlet suite run the same class. Benefit of
the relationship among MIDlet suite members is that they share the same data.

A MIDlet is an event-based application. All routines executed in the MIDlet are invoked
in response to an event reported to the MIDlet by the application manager. The initial
event that occurs is when the MIDlet is started and the application manager invokes
the startApp () method. The startApp () method in a typical MIDlet contains a statement
that displays a screen of data and prompts the user to enter a selection from among one or
more options. The nature and number of options is MIDlet and screen dependent.
A Command object is used to present a user with a selection of options to choose from
when a screen is displayed. Each screen must have a Command Listener. A Command
Listener monitors user events with a screen and causes the appropriate code to execute
based on the current event.

The MIDlet life cycle

A MIDlet is managed by the Java Application Manager, which executes the


MIDlet and controls its life cycle. A MIDlet can be in one of three states: paused, active,
or destroyed.
When first created and initialized, a MIDlet is in the paused state. If an exception
occurs in the MIDlet's constructor, the MIDlet enters the destroyed state and is discarded.
The MIDlet enters the active state from the paused state when its
startApp()method call is completed, and the MIDlet can function normally.
The MIDlet can enter the destroyed state upon completion of the
destroyApp(boolean condition) method. This method releases all held
resources and performs any necessary cleanup. If the condition argument is
true, the MIDlet always enters the destroyed state.

Figure 1. The MIDlet life cycle.

Creating the MIDlet

Before you can run the application, you need to create a new MIDP project in the
J2ME toolkit. To do so, follow these steps in your J2ME Wireless Toolkit:

1. Select Start > Programs > J2ME Wireless Toolkit 2.2 > Ktoolbar. The
toolkit window opens.
2. Create a new project using the Ktoolbar. Enter J2meSyncProject as
the project name and J2meMob as the MIDlet class name. Click on Create Project.

Figure 2. Opening the sample application.


3. The next window lets you specify the project settings. Click OK to accept the defaults.
4. Copy the source file, J2meMob.java.
5. Select Build on the Ktoolbar. You receive the following message:
Project settings saved
Building "J2meSyncProject"
Build complete

Launching the application

To run the example J2meSyncProject application, select Run on the Ktoolbar. The
default emulator shown in Figure 3 should appear.

Figure 3. Opening the sample application,


Running the application
Launch the application, select Menu, and you should be provided with menu options

Vous aimerez peut-être aussi