Tải bản đầy đủ (.pdf) (20 trang)

Web Programming with Java - Introduction to Java docx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (565.75 KB, 20 trang )

1
Web Programming with Java
Introduction to Java
Huynh Huu Viet
Email:
Department of Information Systems
2008 © Department of Information Systems - University of Information Technology
2
Outline
What is Java?
 A little bit history
 Major features
Where Java is used?
 Java, the World Wide Web, and Beyond
Key terms
A Simple Java Program
IDE: NetBeans
Resources
Discussion
2008 © Department of Information Systems - University of Information Technology
3
What is Java?
 An object-oriented programming language
developed by Sun Microsystems
 Also a platform to support Java applications
(technology)
 A little bit history
 1991: A team led by James Gosling at Sun
Microsystems developed Oak, for use in embedded
consumer electronic appliances
 1995: renamed Java - redesigned for developing


Internet applications (Java 1.0 1.1).
 1998: Sun announced the Java 2 platform
(1.2,1.3,1.4)
 2005 - Now: Java 5 (Java 1.5 - newest version 1.7)
2008 © Department of Information Systems - University of Information Technology
4
Java major features (1)
 Simple
 A bit easier C++.
 The clean syntax
 Object-Oriented
 Reuse code
 Distributed
 Designed to make distributed computing easy
 Writing network programs as sending and receiving
data to and from a file.
 Secure:
 Based on the premise that nothing should be trusted.
2008 © Department of Information Systems - University of Information Technology
5
Java major features (2)
Platform-independent
 One program that will run on any platform with
JVM
Portable
 Java programs can be run on any platform
without being recompiled
Multithreaded
 Program’s capability to perform several tasks
simultaneously.

 A necessity in multimedia and network
programming
2008 © Department of Information Systems - University of Information Technology
6
Where Java is used?
Desktop standalone applications
Web applications
 Client side: applets
 Server side: Java servlets or JavaServer
Pages (JSP)
Embedded applications for small
hand-held devices
2008 © Department of Information Systems - University of Information Technology
7
Key terms(1)
 Java language specification (JLS):
 Syntax and semantics of the Java programming
language
 Java API
 Predefined classes and interfaces for developing
Java programs
 JLS is stable, but the API is still expanding
 Java API – 3 Editions
 Java 2 Standard Edition (J2SE): develop client-side
standalone applications or applets
 Java 2 Enterprise Edition (J2EE): develop server-side
applications: Java servlets and JavaServer Pages
 Java 2 Micro Edition (J2ME): develop applications for
mobile devices
2008 © Department of Information Systems - University of Information Technology

8
Key terms(2)
 JDK- Java Development Kit ( SDK -System
Development Kit)
 Programs for developing and testing Java programs
 JRE - Java Runtime Environment
 Programs for running Java programs
 Includes: interpreter, core classes, and supporting files
 A subset of JDK
 IDE- Integrated Development Environment
 Java development tool for rapidly developing Java programs
 Three major IDE:
• JBuilder by Borland ( />• NetBeans Open Source by Sun ( />)
• Eclipse Open Source by IBM ( />)
2008 © Department of Information Systems - University of Information Technology
9
Key terms(3)
2008 © Department of Information Systems - University of Information Technology
10
A Simple Java Program(1)
2008 © Department of Information Systems - University of Information Technology
11
A Simple Java Program(2)
2008 © Department of Information Systems - University of Information Technology
12
Anatomy of a Java Program
Comments
Reserved words
Modifiers
Statements

Blocks
Classes
Methods
The main method
2008 © Department of Information Systems - University of Information Technology
13
Anatomy of a Java Program(1)
 Comments
 Line comment: //
 Paragraph comment : /*…*/
 Reserved words or keywords
 Have a specific meaning to the compiler: class, public…
 Java is case-sensitive
 Modifiers
 Keywords that specify the properties of the data,
methods, and classes and how they can be used.
 public, static, private, final, abstract, and protected
 Statements
 Represents an action or a sequence of actions.
2008 © Department of Information Systems - University of Information Technology
14
Anatomy of a Java Program(2)
 Blocks
 Begins with an opening brace ({)
 Ends with a closing brace (}).
 Classes
 The essential Java construct
 Java program is classes
 Methods:
 Consists of a collection of statements that perform a

sequence of operations.
 The main method
 Defines where the program execution begins
2008 © Department of Information Systems - University of Information Technology
15
Netbeans (1)
2008 © Department of Information Systems - University of Information Technology
16
Netbeans (2)
Sun’s free, open source IDE for Java
Written in Java, available on any
platform that Java is available on
Supports plugins for working in other
languages as well, such as C and C++.
Current Version
 Stable: Netbeans IDE 6.1
 Beta: Netbeans IDE 6.5
Available:
2008 © Department of Information Systems - University of Information Technology
17
Netbeans (3)
2008 © Department of Information Systems - University of Information Technology
18
Resources
 JDK 6:
 /> Java API (chm format):
 /> Netbeans IDE:
 /> Text Books:
 More information at UIT Forum – Course sub-
forum

2008 © Department of Information Systems - University of Information Technology
19
Readings & Exercise
Further Readings
 Chapter 1 [1], Chapter 2 [3]
Exercises:
 [1]: 1.1
 [3]: 2.14
Next week readings:
 [1]: Chapter 2,3,4
2008 © Department of Information Systems - University of Information Technology
20
Discussion

×