Project Facility

Overview

DrJava includes a project facility for managing many files. The project facility allows you to save your open files in a project file, and reopen the project file at a later time to work on some or all of the project files.

New Projects. To create a new project, either select "New" in the Project menu for a project that is initially empty, or select "Save As" in the project menu when you have one or more files already open.

Selecting "Save As" in the Project Menu will create a new project out of the files currently open.

Saving a Project. To save a project, either select "Save" in the Project menu, or select "Save As" in the Project Menu. Note that when you save the project, it only saves the list of files that are in the project, not the files themselves. Saving the project does not save the individual files that are members of the project. Use "Save All" if you wish to save all files as well as the project file to which they belong.

Saving a project will also save which document is currently active, as well as the cursor location in every open document. It will also remember the layout of the project tree, so if some folders are collapsed when the project is saved, then the folders will be collapsed the next time the project is opened.

Opening a Project. To open a project, select "Open" under the Project menu, then select a previously saved project file. You can also open previously open projects in the recent project file list in the project menu. Simply open the Project Menu and click the name of the project file to open that project.

Compiling a Project. There are two options for compiling a project: compiling the open project files, or compiling the entire project. To compile all open project files, select "Compile Open Project Files" under the Project menu, or right click the root of the tree and select "Compile Open Project Files." This will compile all files in the project view including auxiliary files. All files in the external branch (Under the External Files folder) will not be compiled.

Similarly, to compile all project files, even if they are not currently open in DrJava, select "Compile Project" from the Project Menu or the Context menu for the root of the tree. This will compile every source file in the project directory as well as source files in the Auxiliary Files branch.

When not in project view, the "Compile All" button compiles all open files, whereas in project view, "Compile All" only compiles the open project.

Testing a Project. There are two options for testing a project: testing the open project files, or testing the entire project. To test all open project files, select "Test Open Project Files" under the Project menu. This will test all JUnit test files currently open in the Source Files project branch as well as the Auxiliary Files. All files in the external branch (Under the External Files folder) will not be tested.

To test all project files, including files not open in DrJava, choose "Test Project" in the project menu. This will search the project directory (the directory that the project file is saved in) for source files, and test any and all junit test cases it finds. This will also test all test files in the Auxiliary Files branch of the project tree.

Running a Project. To run the main method of a project, select "Run Main Document" under the Project menu. This option is only available if you have specified a file containing the project's main method in the "Project Properties" dialog in the Project menu.

Create Jar File from Project. You can create a jar file that contains the project's source code, its compiled class files, or both by selecting "Create Jar File from Project" in the Project menu. This will display a dialog that allows you to specify the jar file's location and what gets put into it. If you are placing class files into the jar file, you can make the jar file executable by selecting "Make executable" and entering the main class.

Note that you can only put class files into the jar file if you have specified a build directory in the Project Properties and have recently compiled the project.