Comp201: Principles of Object-Oriented Programming I
Spring 2008 -- Projects in DrJava   


DrJava's Project facility allows the developer to organize their work into a cohesive unit.   It allows the developer to

Creating a Project in DrJava

  1. First create a directory that will hold all the code and supplemental materials for your project. Use a folder name that is relevant to the project.
  2. Below that directory, make two subdirectories:
    1. src -- holds all the Java source files.   Put any existing source code you have in here.  If the code is in a package, then put the entire package directory here.
    2. classes -- holds all the compiled class files.
  3. Start DrJava and select Project/New...
  4. Browse to the desired directory for your project, usually your homework directory, e.g. "U:\Comp201\HW03".
  5. A dialog will pop up with project property options for you to fill out:


     

    1. Project Root:  This is where the source files for the project (.java, .dj0, .dj1, .dj2) are to be kept.   Click the "..." button and using the dialog that comes up, create a sub-folder called (by convention) "src".
    2. Build Directory:  This is where the compiled .class files will be created.   It is kept separate from the source files because these are all auto-generated by DrJava.   Click on the "..." button and use the dialog to create a sub-folder called (by convention) "classes".
    3. Working Directory:  This is the directory where the interactions pane and any executing Java programs will expect to find any additional files to load under programmatic control.   Set this either to the same directory as your project, or the classes directory.  The latter will give greater compatibility if you ever decide to run your programs from outside of DrJava from a command line prompt.
    4. Main Document: If you know what class holds the main() function, set the Main Document field to that class in the src directory.
    5. Extra Classpath:  Sometimes auxiliary code will be supplied in the form of Java JAR files.   This is where you would tell DrJava to find these files.
  6. Go to File/Open Folder... and open the src directory (should open by default).   This will bring in any existing code that you have.

 

Adding a File to the Project

Compiling the Project

Testing the Project

Clearing the compiled files

This feature is useful when zipping up project directories when you don't wish to include the compiled class files.

 

 


Last Revised Thursday, 03-Jun-2010 09:50:27 CDT

©2008 Stephen Wong and Dung Nguyen