Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS-1030 Dr. Mark L. Hornick 1 Java Review Interactive.

Similar presentations


Presentation on theme: "CS-1030 Dr. Mark L. Hornick 1 Java Review Interactive."— Presentation transcript:

1 CS-1030 Dr. Mark L. Hornick 1 Java Review Interactive

2 CS-1030 Dr. Mark L. Hornick 2 Java Edit-Compile-Run Cycle Step One: Edit the program. Type in the program, using a text editor, and save the program to a file. Use the name of the main class and the suffix.java for the filename. This file is called a source file.

3 CS-1030 Dr. Mark L. Hornick 3 Java Edit-Compile-Run Cycle Step 2: Compile the source file. The process of compiling the source file creates the bytecode file. The name of the compiler-generated bytecode file will have the suffix.class while its prefix is the same as the source file’s.

4 CS-1030 Dr. Mark L. Hornick 4 Java Edit-Compile-Run Cycle A sample source file and its bytecode file.

5 CS-1030 Dr. Mark L. Hornick 5 Java Edit-Compile-Run Cycle Step 3: Execute the bytecode file. A java interpreter (VM) will go through the bytecode file and execute the instructions in it. If an error occurs while running the program, the interpreter will catch it and stop its execution. The VM starts execution at the bytecode instructions that correspond to the Java statement public static void main()

6 CS-1030 Dr. Mark L. Hornick 6 Java Edit-Compile-Run Cycle The result after the interpreter executes the instructions in the bytecode file.

7 CS-1030 Dr. Mark L. Hornick 7 A program template for simple Java applications.

8 CS-1030 Dr. Mark L. Hornick 8 C++ Edit-Compile-Link-Run Cycle An additional step – Link Step One: Edit the program. Type in the program, using a text editor, and save the program to a file. Use the name of the main class and the suffix.cpp for the filename. This file is called a source file.

9 CS-1030 Dr. Mark L. Hornick 9 C++ Edit-Compile-Run Cycle Step 2: Compile the source file. The process of compiling the source file creates the object file. The name of the compiler-generated object file will have the suffix.obj while its prefix is the same as the source file’s. The object file contains low-level processor- specific instructions, as well as references to functions in other object files or object libraries. It is not executable; i.e. you cannot run an object file.

10 CS-1030 Dr. Mark L. Hornick 10 C++ Edit-Compile-Link-Run Cycle Step 3: Link the object file(s). The process of linking the object file(s) creates the executable file. The name of the linker-generated executable file will have the suffix.exe while its prefix is the same as the primary source file’s. The executable file contains low-level processor- specific instructions; calls to other object libraries are resolved by the linking process. The executable file is runnable.

11 CS-1030 Dr. Mark L. Hornick 11 C++ Edit-Compile-Link-Run Cycle Step 4: Execute the exe file. The operating system’s loader allocates memory for the program to run and loads the machine instructrions from the exe file to memory. The CPU’s Program Counter is set to the beginning of the program corresponding to main() after some initialization code is executed. If a severe error occurs while running the program, the operating system may terminate execution.

12 CS-1030 Dr. Mark L. Hornick 12 Intro to Microsoft VS.NET Interactive

13 CS-1030 Dr. Mark L. Hornick 13 A program template for simple C++ applications. int main(int argc, char* argv[]) { return EXIT_SUCCESS; } Comments Used to describe your program Compiler directives Many uses; one use is to inform the compiler what functions are used Function body Your program.


Download ppt "CS-1030 Dr. Mark L. Hornick 1 Java Review Interactive."

Similar presentations


Ads by Google