[Texas PLT logo]

COMP 402: Production Programming

  DrJava Build Process  

Today's Menu:

DrJava Blog

Please create an account on the DrJava Blog. The site is password-protected; for username and password please contact the instructor.

Beginning next week, please post weekly logs recording your work.

Environment Setup

Today's topics are described in the DrJava Developer Documentation.

On CSNet, you should edit your ~/.bashrc file and set the following environment variables at the end of the file:

You can edit the file by opening a shell (terminal) and typing emacs ~/.bashrc .

You should start a new shell to set these variables. Check that the following commands can be found: java, javac, ant, svn.

You should probably create a directory for all DrJava work, e.g. ~/drjava. Underneath this directory, you should create other directories for your different working copies, e.g. ~/drjava/drjava for your normal copy, ~/drjava/drjava.all for a check-out of the entire trunk, ~/drjava/drjava.4700 for revision 4700, etc.


Check out the latest revision of the main DrJava code using the following command line:

svn co https://drjava.svn.sourceforge.net/svnroot/drjava/trunk/drjava

This tells Subversion (svn) to do a check-out (co) from the specified URL. It creates a directory drjava with the latest versions of the source files. It may ask you if you want to trust the host; say "permanently".

The most commonly used Subversion commands are:

All of these commands have many options and parameters. For the most comprehensive reference, read the Subversion book. You should do this especially before you use more complicated commands, such as svn copy or svn merge to work with branches.

Another useful resource is the SourceForge Subversion HTML interface. It allows you to look at files in your web browser, compare versions, and read the change logs.


After you have checked out the latest revision of the DrJava main source code with the code>svn co command above, change into the drjava directory that was created and look at the directory contents. Here is a description of the files and directories:

Type in ant, ant -p and ant options to get some help for how to use Ant.

ant -p lists all the available targets. The most important targets are:

You should be able to do an ant jar to create a drjava.jar file that you can then run using java -jar drjava.jar . You should also be able to run the unit tests using ant test . Please try these commands to make sure your account is set up correctly.

You will probably not have to edit the build.xml file or know much about Ant internals, but if you want to learn more, please reference the Ant User Manual.

Working on DrJava

You should keep a current copy of the drjava.jar file somewhere convenient, e.g. on your desktop (i.e. ~/Desktop/drjava.jar on CSnet). Run this copy when you work on DrJava (unless it is too buggy, then use a stable or beta version), e.g. by starting it from the command line using:

java -jar ~/Desktop/drjava.jar &

The & tells the shell not to wait until DrJava has finished executing. Instead, you can use the terminal window in parallel.

Check the DrJava code out into a working directory as described above, e.g. into ~/drjava/drjava, then start the drjava.jar file and create a new project for DrJava. The source code you checked out from the Subversion repository does not include a DrJava project file, since the user systems differ too much. You have to create this project yourself. Do not check it into the repository.

We always edit in DrJava, but compile outside DrJava using ant compile from the command line.

As an exercise, do the following:

  1. Open one of DrJava's source files in DrJava, and change it to introduce a compiler error. Then compile from the command line using ant compile. Study the error output.
  2. Before correcting the compiler error, run an svn status and an svn diff from the command line. You should see the change you made. Then use svn revert to undo the change by overwriting it with the file from the repository.
  3. Run DrJava's unit tests using ant test. There should not be any failures.
  4. Open the file StringOpsTest.java and change the code in testReplace() so that the test fails. Then run ant test again and study the error output.
  DrJava Build Process  

URL: http://www.cs.rice.edu/teaching/402/09-spring/lectures/drjava/index.shtml
Copyright © 2008-2010 Mathias Ricken