1 / 30

Java 程序设计

Java 程序设计. Java Programming Fall, 2013. Course Information. Instructor : Name: Tang, Rong( 汤蓉 ) E-mail: tangrong@cuit.edu.cn My Webpage: 教师主页 → 汤蓉 http://home.cuit.edu.cn/Js/PFP/S7L/Default.htm. Course Information. 总学时: 48 学时( Lecture : 30 学时 ; Lab : 12 学时 ; Experiment : 6 学时 .

myrna
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程序设计 Java Programming Fall, 2013

  2. Course Information • Instructor: • Name: Tang, Rong(汤蓉) • E-mail: tangrong@cuit.edu.cn • My Webpage: 教师主页 → 汤蓉http://home.cuit.edu.cn/Js/PFP/S7L/Default.htm

  3. Course Information • 总学时:48学时( • Lecture:30学时 ; • Lab:12学时; • Experiment:6学时. • 先修课程包括:《数据结构》、《面向对象程序设计》等

  4. Course Information • Textbook: • Ken Arnold, James Gosling (著),《The Java Programming Language,3rd Edition》,中国电力出版社 • References: • 郑莉、王行言、马素霞编著,《 Java语言程序设计》,清华大学出版社 • Grady Booch, James Rumbaugh, & Ivar Jacobson (著),《UML 用户指南》,机械工业出版社 • Peter C. Dibble (著) 滕启明 (译),《实时Java平台编程》 机械工业出版社 • 龚天富,侯文永编著, 《程序设计语言与编译》,电子工业出版社

  5. Course Information • Lectures: • Monday, Section 3-4, 1202#; • Wednesday, Section 1-2, 1202# • Week 9th – 16th. • Lab: • Lab: 6306# • Time:(Week 10th -17th) • 计工1201班:???

  6. bilingual • adj.双语的,两种语言的,能说两种语言的 • n.能说两种语言的人

  7. Course Information • Course Evaluation(课程评价) • 平时成绩(考勤,作业和实验报告): 50% • 期末考试(Final Exam): 50% • 期末考试<45分,则:平时成绩计0分; • 如果平时成绩较差,期末考试>=60分,则以期末考试成绩为 该课程成绩。

  8. Requirements • Finish exercises & practice individually and independently • Each assignment must be done individually and independentlyby each student. • You are responsible for ensuring your work is not copied by someone else. • The possible penalties will be applied to all students involved in copying of assignments.

  9. Course Outline Chapter 1: Java语言介绍 Chapter 2: Java程序设计基础 Chapter 3: JVM体系结构 Chapter 4: 类与对象 Chapter 5: Java语言基础语法 Chapter 6: 类的继承 Chapter 7: 接口 Chapter 8: 异常处理 Chapter 9: 多线程程序设计 Chapter 10: Java输入输出(I/O) Chapter 11: Java语言高级特性

  10. Contents for Today • Introduction to Java • Programming Languages • The development process of a Java Program • Translation of Java to machine code • Java Virtual Machine (JVM) • Some Features of Java • Types of Java Programs

  11. Introduction to Java History • 1991James Gosling Develops Oak (renamed Java) language for programming intelligent consumer electronic devices. • 1994 used for World Wide Web applications. • 1995 Oak was renamed “Java” and announced formally to the world by Sun. • Eventually used as a general-purpose programming language because it is object-oriented. • 2009年04月20日,Oracle以74亿美元收购Sun,取得Java的版权。 • 2011年7月28日, Oracle发布Java7的正式版。

  12. Introduction to Java • Three Java Platforms • Java SE — Java (Software Development Kit) Standard Edition, designed for work station development, PC, etc. • Java EE — Java Enterprise Edition, used for enterprise software development and deployment, server, etc. • Java ME— Java Micro Edition, used to develop small electronic devices, such as cell phones, PDA, wireless communication, etc. • 其它应用: • Android是第一个内置支持Java的操作系统,Android自带的应用程序使用Java语言编写。

  13. Some Features of Java • Java 编程语言是个简单、面向对象、分布式、解释性、健壮、安全与系统无关、可移植、高性能、多线程和动态的语言。 • Portable/platform independent • The Java Virtual Machine • Automatic Garbage Collection • No pointers or pointer arithmetic • Multiple inheritance replaced by interfaces, eliminates complexities of multiple inheritance

  14. Programming Languages • Three general types: • High-level Language:Java • looks like everyday English and contains mathematical notations • Assembler Language: • A human readable version of machine language. • Words, abbreviations, letters and numbers replace 0s and 1s • Machine Language: • A collection of binary instructions in the form of strings of 1s & 0s • understood by a specific type of CPU chip.

  15. Programming Languages • Procedure language • Object-oriented language

  16. 数据集合 表示为 问题 结果 传递给 计算 制定 过程集合 Programming Languages • Procedure languageC • action-oriented • Groups of actions (procedures) of a task are formed into functions, and functions are grouped to form programs.

  17. 创建 计算 抽象 问题 类 实例 结果 Programming Languages • Object-oriented language:Java, C++ • models the real-world objects • the unit of programming is the class

  18. Programming Languages • Compiler:C++ • A program that translates from source code to object code. • Source code in this case is normally a high-level language • Object code could be machine code, an intermediate language, or assembly language. • Interpreter: Java • A program that does both program translation and execution • Interpreter translates one statement at a time, and then executes the translated statement. • Source code can be either a high-level language, or an intermediate language.

  19. Source Code (原始程序, t.c) Compiler (Compiling) Object Code (目的程序, t.obj) 其他的目的程序 (Library)函数库 Linker (Linking) Executable Code (可执行程序, t.exe or t.com) Computer Programming Languages Compiler

  20. Source Code (原始程序, Basic, Java) 同 时 翻 译 与 执 行 Interpreter Computer Programming Languages • Interpreter

  21. Java虚拟机(JVM) • A software simulation of a hypothetical computing machine that runs Java bytecodes (Java compiler output). • The Java Virtual Machine allows Java code to be portable between various hardware and OS platforms. • Java虚拟机(JVM)- Java Virtual Machine,它是通过在实际的计算机上用软件模拟各种计算机功能模块虚构出来的一个计算机。Java虚拟机由5个部分组成:一组指令集、一组寄存器、一个堆栈、一个无用垃圾内存单元收集器和一个方法区域。 

  22. Java Virtual Machine (JVM)

  23. JAVA 虚拟机 - JVM • 为什么使用Java虚拟机? • Java语言最重要的特点就是可以在任何操作系统中运行 - 跨平台特性。 • Java编译器生成与平台无关的字节码,作为虚拟机的输入,Java解释器得到字节码后,对其进行解释,使之能在不同的平台下运行。 • 不同的操作系统有不同的虚拟机。 • Java虚拟机的基本原理 • Java虚拟机屏蔽了与具体操作系统平台相关的信息,使得Java语言编译程序只需生成在Java虚拟机上运行的目标代码(字节码),就可以在多种平台上不加修改地运行。 • Java虚拟机在执行字节码时,实际上最终还是把字节码解释成具体平台上的机器指令执行。

  24. The development process of a Java Program • Write:all source code is first written in plain text files ending with the .java extension. • Compile: Those source files are then compiled into .class files by the javac compiler. • .class files--‘Byte code(字节码)’is a standard intermediate-level language. • Run: • A .class file contains bytecodes— the machine language of the Java Virtual Machine (JVM). • The Java launcher tool then runs your application with an instance of the Java Virtual Machine.

  25. Java Source Code (.java) Java Byte Code (.class) Java Compiler Download (optional) .class .class Run Java Virtual Machine A Java Virtual Machine B (Machine Code A) (Machine Code B) The development process of a Java Program

  26. Translation of Java to machine code

  27. Translation of Java to machine code • A two step process Step 1: Compile(编译)source code to Java ‘byte code’. • ‘Byte code(字节码)’is a standard intermediate-level language. • Input: Java code in one or more files ending in .java • Output: Byte code in one or more files ending in .class Step 2: Interpret(解释)Java byte code on a particular machine • The interpreter converts each byte code statement to the specific type of machine code and then runs that machine code.

  28. Local or Remote The Role of the Virtual Machine

  29. 可移植性--Portable/platform independent • 程序的可移植性:指程序不经过修改而在不同的硬件或软件平台上运行的特性。 • 可移植性包括二个层次:源代码级和二进制级的可移植性。 • C、C++仅有一定的源代码级的可移植性。 • Java编译器生成与平台无关的字节码,只要安装了Java运行系统,其程序就可以在任意的处理器上运行 Write Once, Run Anywhere!

  30. Types of Java Programs • Application • Standalone Java program that can run independent of any Web browser • Applet • Java program that runs within a Java-enabled Web browser • Servlet • Java software that is loaded into a Web server to provide additional server functionality ala CGI programs

More Related