![Page 1: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/1.jpg)
Chapter1 Introduction to Java
Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java A Basic Java Application Using OO Java Terminology and Technology Products
CCE JMU China ZhangJM 2008-09
![Page 2: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/2.jpg)
Reference
Thinking in Java (中、英版) The Java Tutorial Sun Microsystems Java™ Programming Language (中、英版) ( 作者: Ken Arnold 、 James Gosling 、 David
Holmes)
Java 程序设计教程 袁兆山等译 机械工业出版社
CCE JMU China ZhangJM 2008-09
![Page 3: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/3.jpg)
Overview of Java
Past Today Future
CCE JMU China ZhangJM 2008-09
![Page 4: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/4.jpg)
• Originally named Oak• Main team members: Bill Joy, Patrick Naughton, Mike Sheridan, James Gosling• Original goal: use with home appliances• In 1994, team realized Oak was perfect for Internet• Announced in May of 1995• First non-beta release in 1996• Java technology is free
The Origin of the Java Programming Language
CCE JMU China ZhangJM 2008-09
![Page 5: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/5.jpg)
CCE JMU China ZhangJM 2008-09
![Page 6: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/6.jpg)
CCE JMU China ZhangJM 2008-09
![Page 7: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/7.jpg)
CCE JMU China ZhangJM 2008-09
![Page 8: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/8.jpg)
Java 的渗透力
CCE JMU China ZhangJM 2008-09
![Page 9: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/9.jpg)
Java belongs to the world
CCE JMU China ZhangJM 2008-09
![Page 10: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/10.jpg)
Joining & Sharing
CCE JMU China ZhangJM 2008-09
![Page 11: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/11.jpg)
CCE JMU China ZhangJM 2008-09
![Page 12: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/12.jpg)
What Is the Java Technology?
Java technology is: A programming language A development environment An application environment A deployment environment
It is used for developing both Applets and Applications
CCE JMU China ZhangJM 2008-09
![Page 13: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/13.jpg)
Java Is A Programming Language
CCE JMU China ZhangJM 2008-09
![Page 14: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/14.jpg)
Java Is A Platform
CCE JMU China ZhangJM 2008-09
![Page 15: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/15.jpg)
Building a Better Language
• Object-oriented
• Distributed
• Multi-threading
• Security
• APIs (pre-written code)
• Easily portable to multiple platforms
(Write Once, Run Anywhere™)
CCE JMU China ZhangJM 2008-09
![Page 16: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/16.jpg)
Primary Goals of the Java Technology
• Provides an easy-to-use language by:
Avoiding many pitfalls of other languages
Being object-oriented
Enabling users to create streamlined and clear code
• Provides an interpreted environment for:
Improved speed of development
Code portability
CCE JMU China ZhangJM 2008-09
![Page 17: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/17.jpg)
Primary Goals of the Java Technology
The following features fulfill these goals:
• The JVM
• Garbage collection
• Code security
CCE JMU China ZhangJM 2008-09
![Page 18: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/18.jpg)
Java Programs
Applets and Applications
• Application – Runs in the operating system
• Applet – Runs in a browser, does smaller tasks
CCE JMU China ZhangJM 2008-09
![Page 19: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/19.jpg)
Basic Components
of a Computer
CCE JMU China ZhangJM 2008-09
![Page 20: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/20.jpg)
CCE JMU China ZhangJM 2008-09
![Page 21: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/21.jpg)
Applicationsmust use
same languages as
operating and
hardware
CCE JMU China ZhangJM 2008-09
![Page 22: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/22.jpg)
Two Ways of Solving the Communication Problem
Compiled
- communicates with only one kind of computer
Interpreted
- communicates with any kind of computer
CCE JMU China ZhangJM 2008-09
![Page 23: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/23.jpg)
CCE JMU China ZhangJM 2008-09
![Page 24: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/24.jpg)
CCE JMU China ZhangJM 2008-09
![Page 25: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/25.jpg)
CCE JMU China ZhangJM 2008-09
![Page 26: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/26.jpg)
CCE JMU China ZhangJM 2008-09
![Page 27: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/27.jpg)
CCE JMU China ZhangJM 2008-09
How Applications Run
![Page 28: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/28.jpg)
HowApplets
Run
CCE JMU China ZhangJM 2008-09
![Page 29: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/29.jpg)
CCE JMU China ZhangJM 2008-09
![Page 30: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/30.jpg)
A First Application in Java //A First Application in Java public class HelloWorld{ public static void main(String[] args){ System.out.println("Hello
World!"); } }
CCE JMU China ZhangJM 2008-09
![Page 31: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/31.jpg)
Run the Application HelloWorld
CCE JMU China ZhangJM 2008-09
![Page 32: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/32.jpg)
A first Applet in Java // A first Applet in Java import javax.swing.JApplet; // 导入 Java API 的 JApplet 类 import java.awt.Graphics; // 导入 Java API 的 JGraphics 类 public class HelloWorldApplet extends JApplet { public void paint( Graphics g ) { g.drawString( "Hello World!", 25, 25 ); } }创建 HTML 文件,以将 HelloWorldApplet.java 编译所得
HelloWorldApplet.class 载入浏览器运行。 HelloWorldApplet.html 文件为:
<html> <applet code="HelloWorldApplet.class" width=300 height=30> </applet> </html>
CCE JMU China ZhangJM 2008-09
![Page 33: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/33.jpg)
Run the applet HelloWorldApplet
CCE JMU China ZhangJM 2008-09
![Page 34: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/34.jpg)
Run the applet HelloWorldApplet
CCE JMU China ZhangJM 2008-09
![Page 35: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/35.jpg)
CCE JMU China ZhangJM 2008-09
![Page 36: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/36.jpg)
CCE JMU China ZhangJM 2008-09
![Page 37: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/37.jpg)
CCE JMU China ZhangJM 2008-09
![Page 38: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/38.jpg)
CCE JMU China ZhangJM 2008-09
![Page 39: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/39.jpg)
CCE JMU China ZhangJM 2008-09
The Java
TechnologyProducts
and Terminology
![Page 40: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/40.jpg)
CCE JMU China ZhangJM 2008-09
![Page 41: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/41.jpg)
CCE JMU China ZhangJM 2008-09
![Page 42: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/42.jpg)
各章内容概述
CCE JMU China ZhangJM 2008-09
![Page 43: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/43.jpg)
CCE JMU China ZhangJM 2008-09
![Page 44: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/44.jpg)
CCE JMU China ZhangJM 2008-09
![Page 45: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/45.jpg)
CCE JMU China ZhangJM 2008-09
![Page 46: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/46.jpg)
CCE JMU China ZhangJM 2008-09
![Page 47: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/47.jpg)
CCE JMU China ZhangJM 2008-09
![Page 48: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/48.jpg)
CCE JMU China ZhangJM 2008-09
![Page 49: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/49.jpg)
CCE JMU China ZhangJM 2008-09
![Page 50: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/50.jpg)
CCE JMU China ZhangJM 2008-09
![Page 51: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/51.jpg)
CCE JMU China ZhangJM 2008-09
![Page 52: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/52.jpg)
CCE JMU China ZhangJM 2008-09
![Page 53: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/53.jpg)
CCE JMU China ZhangJM 2008-09
![Page 54: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/54.jpg)
CCE JMU China ZhangJM 2008-09
![Page 55: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/55.jpg)
CCE JMU China ZhangJM 2008-09
![Page 56: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/56.jpg)
CCE JMU China ZhangJM 2008-09
![Page 57: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/57.jpg)
CCE JMU China ZhangJM 2008-09
![Page 58: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/58.jpg)
CCE JMU China ZhangJM 2008-09
![Page 59: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/59.jpg)
CCE JMU China ZhangJM 2008-09
![Page 60: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/60.jpg)
CCE JMU China ZhangJM 2008-09
![Page 61: Chapter1 Introduction to Java Overview of the Java What Is the Java Technology The Java Virtual Machine A First Application in Java A First Applet in Java](https://reader036.vdocuments.net/reader036/viewer/2022062314/56649f145503460f94c288c1/html5/thumbnails/61.jpg)
CCE JMU China ZhangJM 2008-09