Web Programming with JavaIntroduction to Java Huynh Huu Viet Email: viethh@uit.edu.vn Department of Information Systems... What is Java? An object-oriented programming language develope
Trang 1Web Programming with Java
Introduction to Java
Huynh Huu Viet Email: viethh@uit.edu.vn
Department of Information Systems
Trang 2 What is Java?
A little bit history
Major features
Where Java is used?
Key terms
A Simple Java Program
IDE: NetBeans
Resources
Discussion
Trang 3What 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)
Trang 4Java 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.
Trang 5Java major features (2)
Platform-independent
One program that will run on any platform with JVM
Portable
without being recompiled
Multithreaded
Program’s capability to perform several tasks simultaneously.
A necessity in multimedia and network
programming
Trang 6Where 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
Trang 7Key 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
Trang 8Key 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 ( http://www.borland.com/ )
• NetBeans Open Source by Sun ( http://www.netbeans.org/ )
• Eclipse Open Source by IBM ( http://www.eclipse.org/ )
Trang 9Key terms(3)
Trang 10A Simple Java Program(1)
Trang 11A Simple Java Program(2)
Trang 12Anatomy of a Java Program
Comments
Reserved words
Modifiers
Statements
Blocks
Classes
Methods
The main method
Trang 13Anatomy 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.
Trang 14Anatomy 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
Trang 15Netbeans (1)
Trang 16Netbeans (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
Available: http://www.netbeans.org
Trang 17Netbeans (3)
Trang 18 JDK 6:
http://java.sun.com/javase/downloads/index.jsp
Java API (chm format):
http://www.allimant.org/javadoc/index.php
Netbeans IDE:
http://www.netbeans.org/index.html
Text Books:
sub-forum
Trang 19Readings & Exercise
Further Readings
Chapter 1 [1], Chapter 2 [3]
Exercises:
[1]: 1.1
[3]: 2.14
Next week readings:
[1]: Chapter 2,3,4
Trang 20Discussion