Introduction to Java 09/21/2015

Introduction to Java 09/21/2015

Introduction to Java 09/21/2015 Hsuan-Tien Lin (林軒0) [email protected] Department of Computer Science & Information Engineering National Taiwan University (國Ë台c'xÇ訊工程û) Hsuan-Tien Lin (NTU CSIE) Java 0/11 Historical Once upon a time, when I was a freshman in NTU CSIE ...... • 計程有ix期,上x期YC,下x期YC++ • 計概有ix期,下x期計概YLisp 和Java • i件導向[開ËAL,有一門研v@的x修² Then, in my senior year ...... • 計程計概都變成一x期 • Ï個º都(ëJava 程式:x!、S工、比賽 • i件導向程式設計變成'一下Å修² Then, after I graduated from NTU CSIE ...... • 七t來我沒有再使(NJava, 直02008 t Hsuan-Tien Lin (NTU CSIE) Java 1/11 Is Java/OOP Necessary? When I was interviewing for industrial jobs in the US ...... • bf四¶lø,四¶都O了多型(會Y0) • v-i¶O了virtual function(會Y0) • 待G最}的£¶還O了Java 和C 有U不同(會x續Ð0) Java/OOP 和C 一#,已成ú,技 Hsuan-Tien Lin (NTU CSIE) Java 2/11 What is Java (0/4)? 一個p<0名和生產的咖a • (wikipedia) Java (Indonesian: Jawa) is an island of Indonesia and the site of its capital city, Jakarta. • (wikipedia) Java coffee is a coffee produced on the island of Java. In the United States, the term "Java" by itself is slang for coffee generally. From Java (coffee) to Java (language): (folklore) programmers drink coffee when brainstorming Hsuan-Tien Lin (NTU CSIE) Java 3/11 What is Java (1/4)? a cross-platform language • (1991) a Sun project called Green for consumer electronics (J. Gosling) • target: • device with limited power/resources • devices of different types • Java (Oak) solution (to the second task): text code !(compiler)! byte code =) virtual machine on your TV =) virtual machine on your cellphone =) virtual machine on your Sony DVD player Compile once, run everywhere! Hsuan-Tien Lin (NTU CSIE) Java 4/11 Java Virtual Machine (courtesy of Prof. Chuen-Liang Chen) Compile-time Hardware Environment Environment (()Java Platform) Java Class Loader Java Source & ByteCode Class (.java) Verifier Library Java ByteCodes Java Java Just In Time move locally Compiler Interpreter Compiler or through network Virtual Machine Runtime System Java ByteCodes (.class)(.class) Operating System Hardware OOP Chuen-Liang Chen, NTU CS&IE / 4 Hsuan-Tien Lin (NTU CSIE) Java 5/11 What is Java (2/4)? a Internet-targeted language • (1995) Java and HotJava browser announced • along with the Internet development text code !(compiler)! byte code =) virtual machine in the HotJava browser =) virtual machine on your Windows system with either Netscape or Firefox or IE or chrome =) virtual machine on your Linux system =) virtual machine on your MacOS • applet: a special miniature application in Java suitable for browsers arguably, most important factor for early success Hsuan-Tien Lin (NTU CSIE) Java 6/11 What is Java (3/4)? a popular platform on mobile phones • (wikipedia) Java ME (Micro Edition): Specifies several different sets of libraries for devices which are sufficiently limited that supplying the full set of Java libraries would take up unacceptably large amounts of storage. text code !(compiler)! byte code =) virtual machine on your Nokia phone =) virtual machine on your SE phone =) virtual machine on your Motorola phone =) virtual machine on your BENQ phone regaining popularity nowadays Hsuan-Tien Lin (NTU CSIE) Java 7/11 What is Java (4/4)? an object-oriented language • 更PË化的思­ • 更!D化的設計 • ::: will discuss more later Hsuan-Tien Lin (NTU CSIE) Java 8/11 Your Java Environment • JRE (Java Runtime Environment): for users, JVM + basic libraries • JDK (Java Development Kit): JRE + compilers + ... —jdk-8u60-windows-i586.exe or other platform • Document —jdk-8-doc.zip • some editions: • SE: Standard Edition • EE: Enterprise Edition • ME: Micro Edition ²程²頁上會有Ã考Ç料 Hsuan-Tien Lin (NTU CSIE) Java 9/11 From HelloWorld.c to HelloWorld.java 1 / ∗ HelloWorld.c ∗ / 2 #include <stdio.h> 3 i n t main(){ 4 printf("Hello World \ n " ) ; 5 r e t u r n 0; 6 } 1 / ∗ HelloWorld.java ∗ / 2 import java.lang. ∗ ; 3 p u b l i c class HelloWorld{ 4 / ∗∗ The comment that 5 ∗ w i l l show up in the doc 6 ∗ / 7 p u b l i c static void main(String[] argv){ 8 System.out. println ("Hello World " ) ;// another cmt 9 } 10 } Hsuan-Tien Lin (NTU CSIE) Java 10/11 Your Work Cycle 1 edit your Java source file(s) 2 compile • javac HelloWorld.java • output: HelloWorld.class 3 execute • java HelloWorld 4 generate document • javadoc -d doc/ HelloWorld.java Hsuan-Tien Lin (NTU CSIE) Java 11/11.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us