1 / 16

第一章 Java 簡介

第一章 Java 簡介. 關於 Java. 1990年12月昇陽公司( Sun) 成立 Green Team 小組,發展出 Oak 語言 後因 Oak( 橡樹)這個名稱已被其他語言註冊使用,故而改名為 Java( 爪哇島咖啡) 1995年 Sun 正式推出 Java 語言 高階程式語言 第一個版本 JDK 1.0a2 版本 Java Development Kits. 關於 Java( 續). 特徵 簡單:類似 C++, 但摒除了 goto 、 pointer 及多重繼承等部分 物件導向程式語言 分散式程式語言

Download Presentation

第一章 Java 簡介

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第一章 Java簡介

  2. 關於 Java • 1990年12月昇陽公司(Sun)成立Green Team小組,發展出Oak語言 • 後因Oak(橡樹)這個名稱已被其他語言註冊使用,故而改名為Java(爪哇島咖啡) • 1995年Sun正式推出Java語言 • 高階程式語言 • 第一個版本 • JDK 1.0a2版本 • Java Development Kits

  3. 關於 Java(續) • 特徵 • 簡單:類似C++,但摒除了goto、pointer及多重繼承等部分 • 物件導向程式語言 • 分散式程式語言 • 跨平台程式語言:Windows、Unix、Machintosh • 多執行緒語言:類似multitasking • 網路語言 • Web程式語言

  4. Java的執行環境 Java 程式 編譯 程式 Java Byte Code Java Virtual Machine 解譯 程式 文字編輯器 .class

  5. 工欲善其事,必先利其器 • Java何處尋 • http://java.sun.com • Java 2 SDK的四個部分 • Java環境 • Java語言 • Java API • Application Programming Interface • Java 類別庫(class libraries)

  6. 工欲善其事,必先利其器(續) • Java的版本(Windows、Linux、Solaris) • J2EE • 企業版(Enterprise Edition) • J2SE • 商業版(Standard Edition) • J2ME • 行動版(Micro Edition)

  7. 工欲善其事,必先利其器(續) • 安裝Windows版本的注意事項 • 路徑設定 • Win 2000 • 【開始】【設定】【控制台】【系統】【進階】【環境變數】 • 變數選擇Path後按下【編輯】 • 在變數值中加入【 ;c:\j2sdk1.4.1_02\bin 】 • 紅字部分視安裝Java後所在資料夾而定 • Win XP • 【開始】【控制台】【系統】【進階】【環境變數】 • 選擇【系統變數】中的Path後按下【編輯】 • 餘與Win2000相同

  8. 如何編輯Java語言 • 任何可用的文字編輯器皆可 • Notepad • 【開始】【程式集】【附屬應用程式】【記事本】 • Wordpad • Word • UltraEdit • …

  9. 以NotePad編輯存檔方式 • 【檔案】【存檔】 • 「存檔類型」選擇「所有檔案」 • 「檔名」中的主檔名任意給,附檔名必須為java • sample1.java

  10. Java程式的編譯 • javac編譯程式 Usage: javac <options> <source files> where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output messages about what the compiler is doing -deprecation Output source locations where deprecated APIs are used -classpath <path> Specify where to find user class files -sourcepath <path> Specify where to find input source files -bootclasspath <path> Override location of bootstrap class files -extdirs <dirs> Override location of installed extensions -d <directory> Specify where to place generated class files -encoding <encoding> Specify character encoding used by source files -source <release> Provide source compatibility with specified release -target <release> Generate class files for specific VM version -help Print a synopsis of standard options

  11. Usage: java [-options] class [args...] (to execute a class) or java -jar [-options] jarfile [args...] (to execute a jar file) where options include: -client to select the "client" VM -server to select the "server" VM -hotspot is a synonym for the "client" VM [deprecated] The default VM is client. -cp -classpath <directories and zip/jar files separated by ;> set search path for application classes and resources -D<name>=<value> set a system property -verbose[:class|gc|jni] enable verbose output -version print product version and exit -showversion print product version and continue -? -help print this help message -X print help on non-standard options -ea[:<packagename>...|:<classname>] -enableassertions[:<packagename>...|:<classname>] enable assertions -da[:<packagename>...|:<classname>] -disableassertions[:<packagename>...|:<classname>] disable assertions -esa | -enablesystemassertions enable system assertions -dsa | -disablesystemassertions disable system assertions Java程式的執行 • Java解譯程式

  12. 3 Applet • 可在瀏覽器中執行的Java程式 • Applet本身是 ByteCode,不能直接拿來執行,必須透過瀏覽器中的Java直譯器來解讀它,才可以被執行 1 4 2 c:\java範例\javac sample2.java

  13. 從小程式認識Java

  14. 從小程式認識Java (續) • Java程式是由class (類別)所組成的 • 每一個class必須以左大括號( { )為開始,以右大括號( } )作為class的結束,而class中的敘述都必須以分號( ; )進行結尾 • 將class宣告成public表示在整個程式皆可存取到它 • main()是執行java時會執行的method (方法) • 宣告成public是為了讓其他類別呼叫 • 宣告成static是為了可被自動啟動 • 因為main方法沒有回傳值,因此設定為void • 引數為字串陣列

  15. 從小程式認識Java (續) • 註解(comment) • // • 與C++相同,僅作單行註解 • /*……………*/ • 與C++相同,可進行多行註解 //在螢幕上顯示文字 /*系級:96年班資訊系 學號:962401 姓名:古天樂 */

  16. 從小程式認識Java (續) • 螢幕上輸出 • System.out • 物件(Object) • println • 方法(Method) • (〝這是我的第一個Java程式〞) • 小括號內為顯示於螢幕上的內容

More Related