Introduction to Java CPIT 202
Transcript of Introduction to Java CPIT 202
Introduction to Java Programming
b b h fkdjf
CPIT 202
WEWwwbvxnvbxmnhsgfkdjfcn
1
WEEK 1 LECTURE 1
What is Java?
2
Background on Java
First appear in 1995
Developed by Sun Microsystems Corp.
Cross platform = platform independent
In May 2007, Sun made available most of their Java technologies as free software under GNUJava technologies as free software under GNU General Public License
3
Why Java?
Object Oriented Platform Independent
Simple
IndependentWhy?
bDistributed A li tiRobust Application
SecureMultithreading
4
Java, Web, and Beyond
• Java can be used to develop Web applicationsJava can be used to develop Web applications.
• Java Applets
b li i• Java Web Applications
• Java can also be used to develop applications for hand‐held devices such as Palm and cell phones
5
Examples of Java’s Versatility (A l )(Applets)
6
Examples of Java’s Versatility (A l )(Applets)
7
Examples of Java’s Versatility (W b S A li i )(Web Server Applications)
8
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust• Java Is Robust
• Java Is Secure
• Java Is Architecture‐NeutralJava Is Architecture Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
9
Slides based on course material from Y Daniel Liang
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
Java is partially modeled on C++, but greatly simplified and improved. Some people refer to Java as "C++‐‐" because it is like C++ but
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
with more functionality and fewer negative aspects.
• Java Is Robust
• Java Is Secure
• Java Is Architecture‐NeutralJava Is Architecture Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
10
Slides based on course material from Y Daniel Liang
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
Java is inherently object‐oriented. Although many object‐oriented languages began strictly as procedural languages,
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
Java was designed from the start to be object‐oriented. Object‐oriented programming (OOP) is a popular
h h l• Java Is Robust
• Java Is Secure
• Java Is Architecture‐Neutral
programming approach that is replacing traditional procedural programming techniques.
Java Is Architecture Neutral
• Java Is Portable
• Java's Performance
One of the central issues in software development is how to reuse code. Object‐oriented programming provides
• Java Is Multithreaded
• Java Is Dynamic
Object oriented programming provides great flexibility, modularity, clarity, and reusability through encapsulation, inheritance, and polymorphism.
11
, p y p
Slides based on course material from Y Daniel Liang
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
Distributed computing involves several computers working together on a network. Java is designed to make
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
distributed computing easy. Since networking capability is inherently integrated into Java, writing network
l k d d• Java Is Robust
• Java Is Secure
• Java Is Architecture‐Neutral
programs is like sending and receiving data to and from a file.
Java Is Architecture Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
12
Slides based on course material from Y Daniel Liang
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
You need an interpreter to run Java programs. The programs are compiled into the Java Virtual Machine code called
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
bytecode. The bytecode is machine‐independent and can run on any machine that has a Java interpreter, which is part of h l h ( )• Java Is Robust
• Java Is Secure
• Java Is Architecture‐Neutral
the Java Virtual Machine (JVM).
Java Is Architecture Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
13
Slides based on course material from Y Daniel Liang
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
Java compilers can detect many problems that would first show up at execution time in other languages.
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
Java has eliminated certain types of error‐prone programming constructs found in h l• Java Is Robust
• Java Is Secure
• Java Is Architecture‐Neutral
other languages.
Java has a runtime exception‐handling feature to provide programming supportJava Is Architecture Neutral
• Java Is Portable
• Java's Performance
feature to provide programming support for robustness.
• Java Is Multithreaded
• Java Is Dynamic
14
Slides based on course material from Y Daniel Liang
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust l l• Java Is Robust
• Java Is Secure
• Java Is Architecture‐Neutral
Java implements several security mechanisms to protect your system against harm caused by stray programs.
Java Is Architecture Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
15
Slides based on course material from Y Daniel Liang
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust• Java Is Robust
• Java Is Secure
• Java Is Architecture‐Neutral
Write once, run anywhere
With a Java Virtual Machine (JVM), youJava Is Architecture Neutral
• Java Is Portable
• Java's Performance
With a Java Virtual Machine (JVM), you can write one program that will run on any platform.
• Java Is Multithreaded
• Java Is Dynamic
16
Slides based on course material from Y Daniel Liang
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust• Java Is Robust
• Java Is Secure
• Java Is Architecture‐Neutral Because Java is architecture neutral JavaJava Is Architecture Neutral
• Java Is Portable
• Java's Performance
Because Java is architecture neutral, Java programs are portable. They can be run on any platform without being recompiled
• Java Is Multithreaded
• Java Is Dynamic
recompiled.
17
Slides based on course material from Y Daniel Liang
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust• Java Is Robust
• Java Is Secure
• Java Is Architecture‐NeutralJava Is Architecture Neutral
• Java Is Portable
• Java's PerformanceBecause Java is architecture neutral, Java programs are portable. They can be run on any platform without being
• Java Is Multithreaded
• Java Is Dynamic
on any platform without being recompiled.
18
Slides based on course material from Y Daniel Liang
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust• Java Is Robust
• Java Is Secure
• Java Is Architecture‐NeutralJava Is Architecture Neutral
• Java Is Portable
• Java's PerformanceMultithread programming is smoothly integrated in Java, whereas in other
• Java Is Multithreaded
• Java Is Dynamic
glanguages you have to call procedures specific to the operating system to enable multithreading.
19
Slides based on course material from Y Daniel Liang
Characteristics of Java• Java Is Simple
• Java Is Object‐Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust• Java Is Robust
• Java Is Secure
• Java Is Architecture‐NeutralJava Is Architecture Neutral
• Java Is Portable
• Java's Performance
Java was designed to adapt to an evolving environment. New code can be loaded on the fly without recompilation. There is no need for developers to create and for users to install
• Java Is Multithreaded
• Java Is Dynamic
developers to create, and for users to install, major new software versions. New features can be incorporated transparently as needed.
20
Slides based on course material from Y Daniel Liang
JDK Versions
• JDK 1 02 (1995)JDK 1.02 (1995)• JDK 1.1 (1996)• JDK 1 2 (1998)JDK 1.2 (1998)• JDK 1.3 (2000)• JDK 1 4 (2002)• JDK 1.4 (2002)• JDK 1.5 (2004) a. k. a. JDK 5 or Java 5• JDK 1 6 (2006) a k a JDK 6 or Java 6• JDK 1.6 (2006) a. k. a. JDK 6 or Java 6
21
The Editions of Java
J2SE : Java 2 Standard EditionTo develop client‐side standalone applications or applets
dJ2ME : Java 2 Micro EditionTo develop application for mobile devices such as ll hcell phones
J2EE : Java 2 Enterprise EditionTo develop server‐side applications such as Java servlets and Java ServerPages
22
End of Lecture 1End of Lecture 1