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. The source code is stored in a file called the source file.
DrawSquare
example given earlier, source code would be created and saved in a file named DrawSquare.java
. 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.
DrawSquare
, the source statements in the DrawSquare.java
source file would be compiled to generate the bytecode file DrawSquare.class
.
Figure 1.5 - From Source Code to Running Program
Errors detected by the compiler are called compilation errors.
Compilation errors are actually the easiest type of errors to correct.
If an error occurs while running the program (meaning it compiled successfully), the interpreter will catch it and stop its execution. Errors detected by the interpreter are called run-time errors.
Figure 1.6 - Edit-Compile-Run Cycle for a Java Program
Last modified: December 12, 2022
Back to Program Comments