Compilation Buffers

J can run compilers for languages like Java and C, redirecting the output into a compilation buffer. For some compilers, including javac, jikes, gcc, and Microsoft C/C++, j can also parse the compiler's error messages and jump to the location in the source file where the error occurred. (Please note that on Windows, compilation buffers are only supported for Windows 2000 and Windows XP.)

The command compile, mapped by default to F9, can be used to run make, Ant, or a compiler. You will be prompted for the compile command. The current directory (the directory of the file in the current buffer) is used as the working directory for the execution of the compile command, so if you're using make or Ant, the Makefile or build.xml in the current directory will be used by default.

The command recompile, mapped by default to Ctrl F9, repeats the last compile command you specified. To make this command more useful, you can use the dynamic alias "here" in your compile command to represent the full pathname of the current file (the file in the current buffer).

For example, you could specify the compile command:

        javac -classpath /home/peter/j/src here
Then you could use recompile in any buffer containing a Java source file to run javac (with the specified classpath) on that particular file.

When you start a compilation, j displays the compilation buffer in another window, splitting the current window if necessary. Keyboard focus remains in the source window.

If the compilation completes without error, you can use escape, mapped by default to Escape, to kill the compilation buffer and unsplit the window.

If there are errors, you can use the command nextError, mapped by default to F4, to jump to the location of each error in the source.

In the compilation buffer itself, the command thisError, mapped by default to Enter, jumps to the location in the source file that corresponds to the error message at the current location of the caret. (thisError is also mapped by default to Ctrl Shift G, left button double click, and middle button single click.)

The command showMessage, mapped by default to Alt M, displays the full text of the current error message.

Note that when using jikes, you must specify the +D flag in the compile command (or Makefile) in order for j to be able to parse the error messages correctly:

        jikes +D [...] here