Skip to main content
ICT
Lesson A1 - Introduction to Object Oriented Programming (OOP)
 
Main Previous Next
Title Page >  
Summary >  
Lesson A1 >  
Lesson A2 >  
Lesson A3 >  
Lesson A4 >  
Lesson A5 >  
Lesson A6 >  
Lesson A7 >  
Lesson A8 >  
Lesson A9 >  
Lesson A10 >  
Lesson A11 >  
Lesson A12 >  
Lesson A13 >  
Lesson A14 >  
Lesson A15 >  
Lesson A16 >  
Lesson A17 >  
Lesson A18 >  
Lesson A19 >  
Lesson A20 >  
Lesson A21 >  
Lesson A22 >  
Lesson AB23 >  
Lesson AB24 >  
Lesson AB25 >  
Lesson AB26 >  
Lesson AB27 >  
Lesson AB28 >  
Lesson AB29 >  
Lesson AB30 >  
Lesson AB31 >  
Lesson AB32 >  
Lesson AB33 >  
Vocabulary >  
 

D. Compiling and Running a Program page 6 of 8

  1. A programmer writes the text of a program using a software program called an editor. The text of a program in a particular programming language is referred to as source code, or you can simply use source or code individually. The source code is stored in a file called the source file. For example in the DrawSquare example given above, source code would be created and saved in a file named DrawSquare.java.

  2. Compiling is the process of converting a program written in a high-level language into the bytecode language the Java interpreter understands. A Java compiler will generate a bytecode file from a source file if there are no errors in the source file. In the case of DrawSquare, the source statements in the DrawSquare.java source file would be compiled to generate the bytecode file DrawSquare.class. Classes inside a package, such as the gpdraw.jar, have already been compiled into bytecode for you.


    Figure 1.5 - From Source Code to Running Program

  3. Errors detected by the compiler are called compilation errors. Compilation errors are actually the easiest type of errors to correct. Most compilation errors are due to the violation of syntax rules. These are the basic rules of languages that programmers must follow so that the interpreter understands what to do. It is similar to grammar in a spoken language and varies from language to language.

  4. The Java interpreter will process the bytecode file and execute the instructions in it.

  5. If an error occurs while running the program, the interpreter will catch it and stop its execution. Errors detected by the interpreter are called run-time errors. Run-time errors are usually caused by a fault in the logic of the program, such as accidentally causing the computer to try and divide a number by zero.


    Figure 1.6 - Edit-Compile-Run Cycle for a Java Program

 

Main Previous Next
Contact
 © ICT 2006, All Rights Reserved.