Title: Chapter 1: Introduction
1Xavier University Computer Center Sun
Microsystems, Philippines
Java sa Eskwela (JsE) Program
2Chapter 1
Introduction to Java
3Chapter 1
- Outline
- History of Java
- Java Class Libraries
- Basics of a Typical Java Environment
4Objectives
- To become familiar with how Java evolved
- To understand the Java program development
environment
5Introduction
- Java
- based on C and C
- developed by a team led by Patrick Naughton, Mike
Sheridan, and James Gosling (the Green Project) - developed in early 1991 for intelligent consumer
electronic devices - Market did not develop, project in danger of
being cancelled
6Introduction
- Java
- Internet exploded in 1993, saved project
- Used Java to create web pages with dynamic
content - Java formally announced in 1995
- Now used to create web pages with interactive
content, enhance web servers, applications for
consumer devices (pagers, cell phones)
7Introduction
- both compiled and interpreted language
- vs. C/C source is refined to native
instructions for a particular model of processor - compiled to universal format (byte-code) which is
a set of instructions for a virtual machine
8Introduction
- Java Byte-code
- compiled Java Source
- also called J-code
- executed by a Java run-time interpreter
9Source Code Class temp ..
Java Runtime
Byte-code
PC
Mac
UNIX
10Introduction
- Java Programs
- consist of pieces called classes
- classes contain methods, which perform tasks
- Class libraries
- also known as Java API (Applications Programming
Interface) - rich collection of predefined classes, which you
can use
11Introduction
- Two parts to learning Java
- Learning the language itself, so you can create
your own classes - Learning how to use the existing classes in the
libraries
12Introduction
- Five Phases
- Edit
- Use an editor to type Java program (e.g. vi or
emacs, notepad, Jbuilder, JCreator) - .java extension
- Compile
- Translates program into byte-codes, understood by
Java interpreter - javac command javac myProgram.java
- Creates .class file, containing byte-codes
(myProgram.class)
13Introduction
- Five Phases (continued)
- Loading
- class loader transfers .class file into memory
- Applications run on user's machine
- Applets loaded into Web browser, temporary
- classes loaded and executed by interpreter with
java command - java Welcome
- HTML documents can refer to Java Applets, which
are loaded into web browsers.
14Introduction
- Five Phases (continued)
- Verify
- Byte-code verifier makes sure byte-codes are
valid and do not violate security - Java must be secure Java programs transferred
over networks, possible to damage files (viruses) - Execute
- computer (controlled by CPU) interprets program
one byte-code at a time - performs actions specified in program
15Introduction
Program is created in the editor and stored on
disk.
P1
Editor
Sec. Memory
Compiler creates byte-codes and stores them on
disk.
P2
Compiler
Class Loader
P3
Class loader puts byte-codes in memory.
Sec. Memory
Primary Memory
16Introduction
P4
Verifier
Byte-code verifier confirms that all byte-codes
are valid and do not violate Javas security
restrictions.
Primary Memory
Interpreter reads bytecodes and translates them
into a language that the computer can
understand, possibly storing data values as
the program executes.
P5
Interpreter