Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Our First Java Program Yingcai Xiao. What to Do Set up for Java Programming Write our first Java Program with IDE Write our first Java Program.

Similar presentations


Presentation on theme: "Programming Our First Java Program Yingcai Xiao. What to Do Set up for Java Programming Write our first Java Program with IDE Write our first Java Program."— Presentation transcript:

1 Programming Our First Java Program Yingcai Xiao

2 What to Do Set up for Java Programming Write our first Java Program with IDE Write our first Java Program without IDE Review

3 Programming a Computer

4 Computer Computer: a device for data processing. von Neumann architecture is used by all digital computers. It runs stored programs. It has the following basic components: Memory, IO, CPU, Secondary Storage. Computer Programs are stored instructions for data processing. They are composed of Programming is to define Data Structures to store data and Algorithms to process data.

5 Types of Programming Languages Machine Languages: binary opcodes, hardware dependent. Hard to program and not portable. Programs are called binary code and are understandable by the targeted hardware. Assembly Languages: English-like instructions, platform/OS dependent. Easier to program but not portable. Programs are called assembly code and need to be translated into binary code. High-level Languages: English-like instructions, platform/OS independent. Easy to program and portable. Programs are called source code and need to be translated into binary code.

6 Special Programs Operating System: a program that manages a computer (its memory, CUP, SS, IO (networking)). Compiler: a program that translates source code written in a high-level programming language into binary code. Loader: a program load an executable into memory for execution. Linker: a program that links all related binary codes (libraries) together to make an executable. Editor: a program that can be used to write source code.

7 IDE (Integrated Development Environment) Contains an editor, a compiler, a linker/loader, a debugger, sometimes, a profiler, a source code version controller, and other tools. A complete environment for developing software. Always provides library programs for performing common tasks.

8 Setting Up Your Computer for Java Program Development The lab computers are set for Java program development. Follow the instructions in “Before You Begin” in the textbook to set up your own computer. You can also follow the instructions at

9 Creation of a C++ program Source File (.cpp) Intermediate File (.I) Object File (.obj) Binary File (.exe) PreprocessCompileLink Edit Load

10 Creation of a Java program Source File (.java) Binary Byte File (.class) Native Binary Code Preprocess/CompileJRE/JVM: load/valid/translate/execute Edit

11 Creation of a Java program

12

13 Creation of a Java Program Creation Source code : use a text editor (Notepad) to write the source code. Java source code (.java) is portable to all platforms as long as there is a java compiler. notepad ics.java Compile the source code: Java source code are converted into Java bytecode (.class) by the Java compiler (javac.exe). Java byte code are portable to all platforms as long as there is a Java runtime environment. javac ics.java Run the bytecode: Java bytecode (.class) are executed by the Java virtual machine. java ics

14 Common Binary Code? (Binary Code Reuse Cross OS)

15 Traditional Compilation Source Code for Language 1 Language 1 Compiler on OS1 Binary Code for OS1 OS1 Source Code for Language 1 Language 1 Compiler on OS2 Binary Code for OS2 OS2

16 OS-Independent Code: Intermediate Languages The trend to support machine-independent binary code is to compile the source code into the binary format of an intermediate language. And to provide an interpreter for the intermediate language on each OS to translate the binary code of the intermediate language into the native binary code of the OS.

17 OS-Independent Compilation: Intermediate Language Source Code for Language 1 Language 1 Compiler on OS1 Intermediate Binary Code for Language1 OS1 Intermediate Code Interpreter OS1 OS2 Language 1 Compiler on OS2 Binary Code for OS2Binary Code for OS1 Intermediate Code Interpreter OS2

18 Java Intermediate Language: Java Bytecode Java Source Code (.java) Java Compiler (javac) on OS1 Java Bytecode (.class) OS1 Java Interpreter on OS1 (java) OS2 Java Compiler (javac) on OS2 Binary Code for OS2Binary Code for OS1 Java Interpreter on OS2 (java) Program statements are interpreted one at a time during the run-time.

19 JIT Compiler An interpreter interprets intermediate code one line at a time. Slow execution. A JIT (Just-In-Time) compiler compiles the complete code all at once just into native binary code before execution. Faster execution.

20 JIT Complier: Java Bite Code Compiler Java Source Code (.java) Java Compiler (javac) on OS1 Java Bytecode (.class) OS1 Java JIT Compiler on OS1 OS2 Java Compiler (javac) on OS2 Binary Code for OS2Binary Code for OS1 Java JIT Compiler on OS2 All programming statements are compiled at compile time.

21 .NET OS-Platform-Independence MSIL: Microsoft Intermediate Language (Used by.NET) Source Code for Language 1 Language 1 Compiler on OS1 MSIL Code OS1 MSIL JIT Compiler on OS1 OS2 Language 1 Compiler on OS2 Binary Code for OS2Binary Code for OS1 MSIL JIT Compiler on OS2

22 JIT Compilation in.NET All MSIL code are JIT-compiled to native binary code before execution. No run-time interpretation, faster execution.

23 A Common Language? (Source Code Reuse Cross Languages).NET CTS/CLR

24 .NET Common Language Runtime To make.NET language independent, CLR (Common Language Runtime) is defined as the runtime environment. CLR defines CTS (Common Type System) which should be followed by all languages to be used in the.NET framework. The code that follows CTS standard and runs through CLR is called managed code.

25 .NET Language-Independence CLR: Common Language Runtime Source Code for Language 1 Language 1 Compiler on OS1 MSIL Code Confirming CTS (Managed Code) OS1 CLR on OS1 OS2 Language 2 Compiler on OS2 Binary Code for OS2Binary Code for OS1 CLR on OS2 Source Code for Language 2

26 .NET Architecture for Language and Platform Independence (fan-in and fan-out on MSIL) Source Code for Language 1 Language 1 Compiler on OS1 OS1 CLR for OS1 OS2 Language 2 Compiler on OS2 Binary Code for OS2Binary Code for OS1 CLR for OS2 Source Code for Language 2 MSIL Code Confirming CTS (Managed Code)

27 CLI (Common Language Infrastructure) CLR/CTS for Everyone?

28 CLI : Common Language Infrastructure A specification defines an environment for multiple high-level languages to be used on different computer platforms. Created by Microsoft based on.NET, standardized by MS, Intel, HP and others, ratified by ECMA and ISO..NET is an implementation of CLI for desktop systems..NET Compact Framework is an implementation of CLI for portable devices. Open Source implementations: Mono development platform (Novell), Portable.NET (dotGNU)

29 CLI (Common Language Infrastructure) Specification Open Architecture for Language and Platform Independent Programming Source Code for Language 1 Language 1 Compiler on OS1 OS1 CLR for OS1 OS2 Language 2 Compiler on OS2 Binary Code for OS2Binary Code for OS1 CLR for OS2 Source Code for Language 2 CIL (Common Intermediate Language) Code Confirming CTS (Common Type System)

30 A Common Language for the Internet?

31 A Common Language for the Internet ASCII text (ISO/IEC 8859-1) is platform-independent. => HTTP (Hyper Text Transport Protocol) => Recognizable by all types of computers. (World Wide Web) => Everything is presented as text including data and programs. Tim Berners-Lee => HTML (Hyper Text Markup Language)

32 A Common Language for the Internet  XML (eXtensible Markup Language), can be used to define data and programs over the Internet. => SOAP (Simple Object Access Protocol), XML-based => WSDL (Web Service Description Language), XML-based

33 Web Services Libraries shared over the Internet at run-time. Service interfaces specify what the services can do (contracts). Service interfaces are defined in WSDL (Web Service Description Language) UDDI Registry: Universal Description, Discovery, and Integration. (yellow page) Access Standard: SOAP: Simple Object Access Protocol

34 What did you learn? Computer, programming, data structure, algorithm, programming languages, …


Download ppt "Programming Our First Java Program Yingcai Xiao. What to Do Set up for Java Programming Write our first Java Program with IDE Write our first Java Program."

Similar presentations


Ads by Google