Professional Documents
Culture Documents
1
What Is Java?
An
An object
object oriented
oriented language
language
and
and class
class library
library
Designed by Sun, as a robust alternative to C++
Designed by Sun, as a robust alternative to C++
for
for consumer
consumer electronics
electronics
Developed from scratch
Developed from scratch
Looks
Looks like
like C
C and
and C++
C++
Not
Not as
as complex
complex as
as C++
C++
2
Java Design Criteria
Sun’s
Sun’s Java
Java Language
Language White
White Paper
Paper describes
describes itit as
as
follows:
follows:
“A
“A simple,
simple, object-oriented,
object-oriented, distributed,
distributed, interpreted,
interpreted,
robust,
robust, secure,
secure,
architecture-neutral,
architecture-neutral, portable,
portable,
high-performance,
high-performance, multithreaded
multithreaded and
and dynamic
dynamic
language.”
language.”
3
Platform Independence
Java
Java code
code is
is compiled
compiled into
into
processor-independent
processor-independent bytecodes
bytecodes
Bytecodes
Bytecodes are
are interpreted
interpreted by
by the
the
Java
Java Virtual
Virtual Machine
Machine (VM)
(VM) at
at run
run
time
time
Compile Java VM
4
The Java Virtual Machine (VM)
Java
Java programs
programs run
run within
within the
the
Java
Java VMVM
Java VM must be ported to the
Java VM must be ported to the
platform
platform
Java VM is built into Web
Java VM is built into Web
browsers
browsers
Java application or applet
Java Virtual Machine (VM)
Browser or other container
Native operating system (for example, NT)
5
More About the Java VM
The
The VMVM loads
loads classes
classes as
as necessary
necessary from
from the
the local
local
disk,
disk, or
or over
over the
the network
network
The VM verifies classes for correct usage
The VM verifies classes for correct usage
No
No illegal
illegal Java
Java bytecodes
bytecodes
No
No invalid
invalid register,
register, stack,
stack, or
or data
data type
type usage
usage
The
The VM
VM performs
performs garbage
garbage collection
collection
6
Just-in-Time (JIT) Compilers
VMs
VMs can
can perform
perform just-in-time
just-in-time compilation:
compilation:
Translate
Translate bytecode
bytecode to
to native
native instruction
instruction
Optimize repetitive code, such as loops
Optimize repetitive code, such as loops
Useful if the same bytecodes are executed time
Useful if the same bytecodes are executed time
and
and again
again
7
Java Applets
The
The most
most common
common useuse of
of Java
Java
Intended for use within HTML pages
Intended for use within HTML pages
Add active content
Add active content
Forms,
Forms, audio,
audio, images,
images, video
video
Appear
Appear in
in aa browser,
browser, and
and can
can communicate
communicate with
with
the
the server,
server, ifif needed
needed
8
Java Applications
Suitable
Suitable for
for client
client or
or server
server deployment
deployment
Standalone
Standalone client-side
client-side applications
applications
Server-side
Server-side applications
applications that
that serve
serve multiple
multiple clients
clients
Standalone
Standalone applications:
applications:
Java
Java VM
VM runs
runs standalone
standalone
No
No need
need to
to load
load classes
classes over
over network
network
9
Java and Network Computing Architecture
(NCA)
NCA
NCA consists
consists of
of three
three distinct
distinct tiers:
tiers:
10
Summary
Java
Java code
code is
is compiled
compiled into
into
platform-independent
platform-independent bytecodes
bytecodes
Bytecodes are interpreted by Java VM
Bytecodes are interpreted by Java VM
Applets run in a browser on the client
Applets run in a browser on the client
Java applications run standalone, on the client or
Java applications run standalone, on the client or
server
server
JavaBeans are reusable components
JavaBeans are reusable components
11