Building the Project
The project is in a standard set of OpenJDK repositories. You
can either clone the entire forest, and build a complete standalone
version of OpenJDK containing the new compiler, or you can just
clone and build the
langtools to get a copy of
For general details on building OpenJDK, see the OpenJDK Build README.
In addition to all the normal dependencies for OpenJDK, to build
langtools repository, you need to download ANTLR
3.1.1 or later. There are two different bundles you can use.
For more details and other versions, see the ANTLR download page. Note that the version number is currently specified in the ANTLR jar file name, so if you use a newer version, you will have to update the langtools make/build.xml file accordingly.
When you build the langtools repository, you must set the
antlr.home to a directory that contains
lib/antlr-3.1.1.jar. If you download the full ANTLR
source distribution, you can simply set
the location where you unpack the bundle. If you just download the
ANTLR 3.1.1 jar file, you must set up a directory to contain
lib/antlr-3.1.1.jar and set
point to that directory.
Assuming you have suitable copies of JDK and ANTLR 3.1.1
installed, the following commands will download and build the
% cd work % hg clone http://hg.openjdk.java.net/compiler-grammar/compiler-grammar/langtools % cd langtools % ant -f make/build.xml \ -Dboot.java.home=/opt/jdk/1.6.0 -Dantlr.home=/opt/antlr/3.1.1 build-javac
Once you have built javac in the langtools repository, the
dist directory will contain a copy of the javac
dist/lib/javac.jar. You can use this jar
file in a number of ways.
Execute it directly in the standard way.
% java -jar dist/lib/javac.jar ...
Use the simple wrapper script provided in
% dist/bin/javac ...
Put the jar file on the bootclasspath used by the standard javac launcher.
% javac -J-Xbootclasspath/p:dist/lib/javac.jar ...
Note the use of -J to set the bootclasspath used to locate the classes for javac. (By itself, -Xbootclasspath is a javac option used to locate the runtime classes used when compiling your program.)