Download slides

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
Introduction
Read
D&D Sec 1.8; Sec 1.13
THE Java tutorial http://java.sun.com/docs/books/tutorial/
1
About Java
• Developed by Sun Microsystems
• Originally intended for intelligent
consumer-electronic devices (smart
refrigerators, microwave ovens, toasters..)
2
About Java (cont.)
Java Evolved into a general-purpose,
high-level Java programming language
which
• Provides a powerful software platform
for the development of applications.
• Allows writing applets for the Web
– An applet is a program that runs within a
Java-enabled browser.
3
Java Applications: Servers
A Java server is a special kind of a
Java application which serves and
supports client programs on a
network
• Examples of servers:
– Mail servers
– Proxy serves
– Print servers
4
A Servlet
Another specialized java program
– Can almost be thought of as an applet that
runs on the server side.
– Servlets are similar to applets in that they are
runtime extensions of applications
– Instead of working in browsers, servlets run
within Java Web servers, configuring or
tailoring the server
5
Basics of a Typical Java
Environment (Sec 1.13)
• Java is unusual in that a program is both
compiled and interpreted
• Java programs normally undergo five
phases
– Edit
Programmer writes program (and stores program
on disk)
– Compile
Compiler creates platform-independent codes
called Java bytecodes
6
Java Environment (cont.)
– Load
Class loader stores bytecodes in memory
– Verify
Verifier ensures bytecodes do not violate
security requirements
– Execute
Interpreter translates bytecodes into
machine language
7
Phase 1
Editor
Disk
Program is created in
an editor and stored
on disk in a file ending
with .java.
Phase 2
Compiler
Disk
Compiler creates
bytecodes and stores
them on disk in a file
ending with .class.
Primary
Memory
Phase 3
Class Loader
Disk
Phase 4
Bytecode
Verifier
. ..
..
.
Class loader reads
.class files
containing
bytecodes from
disk and puts
those bytecodes
in memory.
Primary
Memory
Bytecode verifier
confirms that all
bytecodes are valid
and do not violate
Java’s security
restrictions.
. ..
..
.
Primary
Memory
Phase 5
Interpreter
. ..
..
.
Interpreter reads
bytecodes and
translates them into
a language that the
computer can
understand,
possibly storing
data values as the
program executes.
Fig. 1.1 Typical Java environment.
8
9
Java Virtual Machine (Java VM).
• Think of Java bytecodes as the machine
code instructions for the Java Virtual
Machine (Java VM).
• A Java interpreter is an implementation
of the Java VM
• A Java interpreter can be:
– A development tool that runs aplications
– A Web browser that can run applets
10
Java Portability
• Java bytecodes help make "write once, run
anywhere" possible.
– You can compile your program into bytecodes
on any platform that has a Java compiler.
– The bytecodes can then be run on any
implementation of the Java VM.
• Java portability:
As long as a computer has a Java VM, the
same program written in Java can run on
Windows 2000, a Solaris workstation, or on
an iMac
11
12
Related documents