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
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
Overview of Java
Past Today Future
CCE JMU China ZhangJM 2008-09
• 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
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
Java 的渗透力
CCE JMU China ZhangJM 2008-09
Java belongs to the world
CCE JMU China ZhangJM 2008-09
Joining & Sharing
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
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
Java Is A Programming Language
CCE JMU China ZhangJM 2008-09
Java Is A Platform
CCE JMU China ZhangJM 2008-09
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
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
Primary Goals of the Java Technology
The following features fulfill these goals:
• The JVM
• Garbage collection
• Code security
CCE JMU China ZhangJM 2008-09
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
Basic Components
of a Computer
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
Applicationsmust use
same languages as
operating and
hardware
CCE JMU China ZhangJM 2008-09
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
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
How Applications Run
HowApplets
Run
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
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
Run the Application HelloWorld
CCE JMU China ZhangJM 2008-09
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
Run the applet HelloWorldApplet
CCE JMU China ZhangJM 2008-09
Run the applet HelloWorldApplet
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
The Java
TechnologyProducts
and Terminology
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
各章内容概述
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09
CCE JMU China ZhangJM 2008-09