Chapter 6. Compiling Programs

Table of Contents

Compiling Files
Viewing Compiler Errors
Selecting a Compiler

Java compilers check your programs for errors and translate them to class files which can be used. Any time you change the source file for a class, it must be compiled before it can be used. To do this in DrJava, you can simply click on the "Compile All" button on the toolbar to compile any open documents. Any resulting errors will be highlighted in the document.

Compiling Files

To compile the documents you have open in DrJava, click on the "Compile All" button on the toolbar, or choose either "Compile All" or "Compile Current Document" from the Tools menu. Before the compilation can begin, all open files must be saved, even if only the current document is being compiled. This is necessary because one file can depend on other files, and it is important that no files have been modified when errors are displayed. (Otherwise, an error could be highlighted on a line which has changed.) Once a compilation completes successfully, the Interactions Pane is reset so that the new class files can be used. The output on the Console Tab is also reset to begin the new session, unless the "Clear Console After Interactions Reset" option in the "Miscellaneous" section of the Preferences is unchecked.

In project mode, you have the option to compile all project source files, even if those files are not currently open in DrJava. To compile all source files, click "Compile Open Project Files" in the Project Menu. This option is also available by right clicking the root of the project tree.