18
Java, 1-1 Chapter 01 Introduction Course Overview Some Programming ( 程程 ) Languages ( 程程 ) Installation ( 程程 ) and Use ( 程程 ) of JDK Lectures / Handout Username: Jav@ Password: AQm65

Chapter 01 Introduction

  • Upload
    hova

  • View
    23

  • Download
    2

Embed Size (px)

DESCRIPTION

Chapter 01 Introduction. Course Overview Some Programming ( 程式 ) Languages ( 語言 ) Installation ( 安裝 ) and Use ( 使用 ) of JDK Lectures / Handout Username: Jav@       Password: AQm65. Teaching ( 教學 ) Style ( 風格 ) in this Class ( 課程 ). - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 01 Introduction

Java, 1-1

Chapter 01 Introduction

Course Overview Some Programming ( 程式 ) Languages ( 語

言 ) Installation ( 安裝 ) and Use ( 使用 ) of JDK Lectures / Handout

Username: Jav@       Password: AQm65

Page 2: Chapter 01 Introduction

Java, 1-2Teaching ( 教學 ) Style ( 風格 ) in this Class ( 課程 )

Caveat: English ( 英文 ) is my secondary ( 次要的 ) language ( 語言 ). Please raise your hand ( 舉手 ) ANYTIME if you

have any concerns Motivating examples implemented in Java and demo

during the class Bring your textbook or Codes in the computers

You practice some exercises during the class (if we have time) and at home

Web page: Due date and requirement of homework assignment

Learning ( 學習 ) Chinese ( 中文 ) along the way

Page 3: Chapter 01 Introduction

Java, 1-3

Introduction

Core ( 核心 ) of book Program clarity ( 清晰 ), using both structured ( 結

構化 ) and object-oriented ( 物件導向 ) programming ( 程式設計 )

Big book, cover half, good for future reference Java

Powerful, object-oriented language Fun to use for beginners, appropriate for

experienced programmers Language of choice for Internet ( 網際網路 ) and

network ( 網路 ) communications ( 通訊 )

Page 4: Chapter 01 Introduction

Java, 1-4

Live-Code Learning Textbook approach: Use the language to teach the

language Learning by examples is the key to rapid mastery Practicing Java regularly is essential for success This book is geared for novice programmers, so the

authors stress clarity ( 清晰 ) New concepts highlighted in the text and codes

Line numbers for the code, easier to refer to in the text Download example programs

www.deitel.com/books/jhtp8 or Lectures / Handout

Page 5: Chapter 01 Introduction

Java, 1-5

Programming Tips Good Programming Practices Common Programming Errors ( 錯誤 ) Testing and Debugging Tips Performance ( 性能 ) Tips Portability Tips Software ( 軟體 ) Engineering ( 工程 ) Observations Look-and-Feel Observations

Page 6: Chapter 01 Introduction

Java, 1-6

Two Approaches to Programming 1/2 (1) Structured programming ( 結構化程式設計 )

An approach to software development whereby a program is defined as a set of logical processes, which may not be carried out sequentially.

By taking the structured approach to programming, developers create software that is efficient in its execution.

Structured programming languages are based on functions ( 函數 ), subroutines, or procedures.

Page 7: Chapter 01 Introduction

Java, 1-7

Two Approaches to Programming 2/2

(2) Object-oriented programming (OOP) ( 物件導向程式設計 ) Allows a programmer to think modularly because

programs are assembled into components called objects. Objects: Building blocks of OOP, are reusable,

modular components. An object is a self-contained unit containing functions and attributes.

Hardware component OOP builds on and enhances structured programming

Page 8: Chapter 01 Introduction

Java, 1-8

Programming Style Object-Oriented Programming (chapters 3, 8, 9, 10)

Java classes ( 類別 ) and objects ( 物件 ) Program design ( 設計 )

Structured Programming (chapters 4, 5, 6) Java class methods ( 方法 ) Program implementation ( 實現 ) Disciplined approach to writing programs Clear, easy to test, debug ( 移去錯誤 ), and modify

Page 9: Chapter 01 Introduction

Java, 1-9

C and C++ C: Developed between 1969 and 1973 by Dennis

Ritchie at the Bell Laboratories Evolved from BCPL and B Most widely used language among professional

software developers for commercial applications Unix

1969 by a group of AT&T employees at Bell Labs First in assembly language, recoded in C in 1973 (Berkeley) BSD, (Sun’s) Solaris, Linux, Android

(object-oriented programming) C++ evolved from C Developed by (Danish) B. Stroustrup in 1979 at Bell

Labs

Page 10: Chapter 01 Introduction

Java, 1-10

Java• Java evolved from C++, which evolved from C• Developed in 1991 for intelligent consumer electronic

devices by James Gosling of Sun Microsystems Market did not develop, in danger of being cancelled

Internet exploded in 1993, saved project Used Java to create web pages with dynamic content

Java formally announced in 1995 by Sun Now used to create web pages with interactive content,

enhance web servers, applications for consumer devices (handheld devices, cell phones)...

Sun: Part of Oracle

Page 11: Chapter 01 Introduction

Java, 1-11

Java Products Groups This book is based on Java Standard ( 標準 ) Edition

( 版本 ) (Java SE) 6, Update 11 Develop and deploy Java applications on desktops

and servers, as well as in today's demanding embedded environments.

Java Enterprise ( 企業 ) Edition (Java EE) Develop large-scale, distributed networking

applications and web-based applications. Java Micro ( 微小的 ) Edition (Java ME)

Develop applications for small, memory-constrained devices, such as cell phones, pagers and PDAs.

Page 12: Chapter 01 Introduction

Java, 1-12

1.10 Java Class Libraries Java programs

Consist of pieces called classes ( 類別 ) Classes contain methods ( 方法 ), which perform tasks

Class libraries Java API (Applications Programming Interface) Rich collection of predefined classes which you can use Have better performance ( 性能 ) Improve program portability Download the Java API documentation

java.sun.com/javase/downloads/

Page 13: Chapter 01 Introduction

Java, 1-13

What’s on the CD-ROM? What you are required to use:

Java SE Development Kit (JDK) 6 Update 11 (jdk-6u11-windows-i586-p.exe), available on CD-ROM (directory software\Sun) 或上網找最新版

html/software/install.htm: System Requirements, Running the JDK Installer, Troubleshooting (or Before You Begin in the book)

Other stuff (optional): Java integrated development environment (IDE):

NetBeans, Eclipse MySQL

Page 14: Chapter 01 Introduction

Java, 1-14Setting ( 設定 ) the PATH ( 路徑 ) Environment Variable

設定路徑: Use javac, java, … under any directory

Windows 2000/Vista/Win 7: 開始 > 設定 > 控制台 > 系統 > 進階 > 環境變數 > 系統變數 > Path 下加入 c:\Program Files\Java\jdk1.7.0_45\bin; ( 說明 )

其中的 jdk1.7.0_45 隨您的版本而定

Page 15: Chapter 01 Introduction

10-15

打開檔案總管,到達檔案所存放的位置, 按 Shift + 滑鼠右鍵, 選 『在此處開啟命令視窗』

File extension .java (a text file) 檔案總管,工具 / 選項 / 檢視,隱藏或顯示副檔

名 C:\> javac GravityGame.java

使用編譯器 (compiler) javac 編譯,產生 GravityGame.class

C:\> java GravityGame

執行 GravityGame.class

使用 Java 的步驟

Page 16: Chapter 01 Introduction

Java, 1-16

Development steps (1) Edit (e.g., with Notepad or Emacs) with file

extension .java (a text file)

• 檔案總管 (file manager) ,工具 (tool) / 選項 (option) / 檢視,隱藏 (hide) OR 顯示 (show up) 副檔名

(2) Compile (with compiler ( 編譯器 ) javac)

• Produce bytecodes ( 位元組碼 ), understood by Java interpreter, as a file *.class that will be interpreted during the execution phase

Typical Java Development Environment (1/2)

Page 17: Chapter 01 Introduction

Java, 1-17

Typical Java Development Environment (2/2)

Run-time steps (3) Load: Class loader (application or applet) takes the

.class file and transfers it to memory• C:\> java Welcome

(4) Verify: Check that downloaded classes are valid and do not violate Java’s security restriction

(5) Execute ( 執行 ): Bytecodes are executed by the Java Virtual Machine (JVM)

• Virtual machine: A software application that simulates a computer. Hides the underlying operating system and hardware from the programs that interact with it.

Page 18: Chapter 01 Introduction

Java, 1-18

Professional Conduct 50-minute classes with 10-minute break

Please handle your personal matter during the breaks. Please do NOT use keyboard or mouse while I am teaching.

Hear sound my voice sore throat Way of big-room learning: Some feel easy (review) while some

feel difficult (catch up) You are encouraged to discuss with your classmates during practice

time. But you need to write your own code. No plagiarism. Please bring your class note and homework handout. And MIND.

Method of happy learning Work hard during the class More time to play during your free time