08/13/14
Võ Phương Bình - ITFAC - DLU
1
Chapter 1: Introduction to Java
Chapter 2: Primitive Data Types and
Operations
Chapter 3: Control Statements
Chapter 4: Methods
Chapter 5: Arrays
Part I: Fundamentals of
Programming
08/13/14
Võ Phương Bình - ITFAC - DLU
2
Chapter 1:
Introduction to Java
What Is Java?
Getting Started With Java Programming
Create, Compile and Running a Java
Application
08/13/14
Võ Phương Bình - ITFAC - DLU
3
What Is Java?
History
Applications of Java
Compare to C/C++/C#
Characteristics of Java
08/13/14
Võ Phương Bình - ITFAC - DLU
4
History
James Gosling and Sun Microsystems
(1983-1984)
Oak
In a project of electric device
developing
Java, May 20, 1995, Sun World
HotJava
The first Java-enabled Web browser
JDK Evolutions
J2SE, J2ME, and J2EE
08/13/14
Võ Phương Bình - ITFAC - DLU
5
JDK Versions
JDK 1.0 (1995)
JDK 1.1 (1996)
Java 2 SDK v 1.2 (JDK 1.2, 1998)
Java 2 SDK v 1.3 (JDK 1.3, 2000)
Java 2 SDK v 1.4 (JDK 1.4, 2002)
Java 5 SDK v 1.5 (JDK 1.5, 2005)
08/13/14
Võ Phương Bình - ITFAC - DLU
6
JDK Editions
Java Standard Edition (J2SE)
J2SE can be used to develop client-side standalone
applications or applets.
Java Enterprise Edition (J2EE)
J2EE can be used to develop server-side applications such as
Java servlets and Java ServerPages.
Java Micro Edition (J2ME).
J2ME can be used to develop applications for mobile
devices such as cell phones.
JDK Editions (2)
08/13/14
Võ Phương Bình - ITFAC - DLU
7
Java2
Standard Edition
(J2SE™)
Java2
Enterprise Edition
(J2EE™)
Java2
Micro Edition
(J2ME™)
Java 2 Platform
Standard desktop &
workstation applications
Heavy duty server
systems
Small & memory
constrained devices
08/13/14
Võ Phương Bình - ITFAC - DLU
8
Java IDE Tools
Eclipse
Borland Jbuilder
NetBean
Microsoft Visual J++, J#
WebGain Café
IBM Visual Age for Java
Forte by Sun Microsystems
08/13/14
Võ Phương Bình - ITFAC - DLU
9
Applications of Java
JAVA
Mobile
Mobile
Console
Console
GUI
GUI
Network
Network
Web
Web
Database
Database
RMI
RMI
Applet
Applet
08/13/14
Võ Phương Bình - ITFAC - DLU
10
Console
08/13/14
Võ Phương Bình - ITFAC - DLU
11
GUI (with JFC)
08/13/14
Võ Phương Bình - ITFAC - DLU
12
Applet & Web
08/13/14
Võ Phương Bình - ITFAC - DLU
13
Database & Web
08/13/14
Võ Phương Bình - ITFAC - DLU
14
Mobile
08/13/14
Võ Phương Bình - ITFAC - DLU
15
Compare to C/C++/C#
Similar to C/C++/C#
Difference:
Compiler
08/13/14
Võ Phương Bình - ITFAC - DLU
16
Traditional Compiler (C/C++)
08/13/14
Võ Phương Bình - ITFAC - DLU
17
Java Compiler
08/13/14
Võ Phương Bình - ITFAC - DLU
18
Characteristics of Java
Java is simple
Java is object-oriented
Java is distributed
Java is robust
Java is secure
Java is architecture-neutral
Java is multithreaded
Java is dynamic
08/13/14
Võ Phương Bình - ITFAC - DLU
19
Getting Started with Java
Programming
A Simple Java Application
Compiling Programs
Executing Applications
08/13/14
Võ Phương Bình - ITFAC - DLU
20
A Simple Application
Example 1.1
//This application program prints Welcome
//to Java!
package chapter1;
public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to
Java!");
}
}
08/13/14
Võ Phương Bình - ITFAC - DLU
21
Creating and Compiling Programs
On command line
javac file.java
Source Code
Create/Modify Source Code
Compile Source Code
i.e. javac Welcome.java
Bytecode
Run Byteode
i.e. java Welcome
Result
If compilation errors
If runtime errors or incorrect result
08/13/14
Võ Phương Bình - ITFAC - DLU
22
Executing Applications
On command line
java classname
Java
Interpreter
on Windows
Java
Interpreter
on Sun Solaris
Java
Interpreter
on Linux
Bytecode
08/13/14
Võ Phương Bình - ITFAC - DLU
23
Example
javac Welcome.java
java Welcome
output:
08/13/14
Võ Phương Bình - ITFAC - DLU
24
Compiling and Running a Program
Where are the
files stored in the
directory?
c:\example
chapter1
Welcome.class
Welcome.java
chapter2
.
.
.
Java source files and class files for Chapter 2
chapter19
Java source files and class files for Chapter 19
Welcome.java~
08/13/14
Võ Phương Bình - ITFAC - DLU
25
Anatomy of a Java Program
Comments
Package
Reserved words
Modifiers
Statements
Blocks
Classes
Methods
The main method
Input processing