javac

The Sun Java compiler, javac, is used to build DrJava. The DrJava application also interfaces, at runtime, with the user's javac compiler. See the JDK section of Getting Started for installation instructions.

Documentation on the javac command can be found with Sun's Java tools documentation.

Compilation Paths

There are a number of search paths used as parameters to perform compilation. To avoid confusion, it's important to be familiar with the distinction between them.

  • The boot class path is the location of the standard Java APIs. It is conceptually prepended to the standard class path whenever a search for a class occurs. By default, this is the location of the APIs used to run the compiler; it is only necessary to manipulate this setting if compilation should occur against a different or customized version of the APIs.

  • The class path points to additional libraries and classes used for compilation. For example, if JUnit tests are to be compiled, the junit.jar file should be on the class path. If iterative updates are to be made to the sources (as is usually the case), the location of the compiled classes should be part of the class path as well.

  • The source path is the location of source files that, while not explicitly required to be compiled, can be automatically compiled if the classes they define are needed. This allows, for example, the compilation of a single source file to silently trigger the compilation of many others. Since such on-demand processing changes the compiler's internal symbol tables on-the-fly, however, it's generally not a good idea to take advantage of this feature — changing the order in which sources are passed to the compiler can change the meaning of the program! A better alternative is to simply list all sources that need to be compiled explicitly (Ant and DrJava do this easily and automatically), and set the source path to an empty string.

  • The compiler JVM boot class path is the location of the Java APIs used to run the compiler. Since javac is implemented in Java, it runs in a JVM, and that JVM needs access to the standard APIs. It's important to note that there need not be any relationship between this value and the compilation boot class path. The javac command should automatically set up this parameter correctly.

  • Similarly, the compiler JVM class path is the location of additional libraries and classes used to run the compiler. Typically, the classes implementing the compiler are found in a tools.jar file, and that jar file will need to be on the compiler JVM class path. Again, there need not be any relationship between this value and the compilation class path. And the javac command will automatically set this correctly.