CECS-174: Configuring DrJava's Preferences

DrJava is a Java Integrated Development Environment (IDE). Unlike industry-standard IDE's (e.g.: Eclipse, NetBeans, MS Visual Studio), DrJava is meant for use beginning programmers. DrJava removes many of the features available by default with other IDE's that overwhelm novice programmers. This page shows you how to configure DrJava for use in the CECS174 programming class.

You will need to do this every time you login to a computer in the CECS lab since such configuration changes are wiped clean overnight (or when you use a different computer).

You should only need to do this once on your own personal computer. Any changes you make are saved under the account you use for your computer.

Note, DrJava saves the preferences you change in a file named .drjava inside of your Documents and Settings folder for you account. So, if you want to avoid having to specify the settings repeatedly, you could copy this file to your CECS account and transfer it to the local computer before starting DrJava. See your instructor if you want to do this.

Start DrJava

The DrJava program is available via the Start Menu. It is installed in the directory C:\intro-to-prog. Here are the steps to start DrJava -- it takes about two minutes for DrJava to start, so be patient.

  1. Click on Start Menu
  2. Click on the Programs category
  3. Click on CECS 174 - Intro to Java
  4. Click on DrJava

Here is a figure showing you these steps:

Edit Preferences

In order to use the Multimedia Java Classes (bookClasses folder) provided by the authors, we need to change one setting in DrJava's preferences to specify the location of these files. In Java programming, this is known as setting the classpath and what you specify are directories (or JAR files) that have user-defined (really developer-defined) classes and packages. Via this mechanism, the Java Virtual Machine will know to look in the locations specified in the classpath for any classes that are not part of the Java language.

Here are the steps to specify that the classpath include the bookClasses folder

  1. Click on the Edit Menu and choose Preferences. This will bring up a popup window as shown below:
  2. Click on the Add button in the middle of the popup window to add another location to the classpath.
  3. Use the browser window that pops up to locate your local copy of the CECS174 folder. If you followed the instructions on this site, this folder will be located in your My Documents\MyProjects folder.
  4. Select (do not double-click) the bookClasses folder. See next two images for additional guidance.
  5. Click on the Apply button followed by the OK button to complete changing the preferences.

Reset of Interactions Pane

Now that we've pointed DrJava to the bookClasses folder containing Java code provided by the authors of the book, we need to reset the DrJava environment so we can start using this code in the Interactions pane. To do this click the Reset button on the top-right part of the DrJava window and then click Yes on the popup window.

Testing your environment: Show a Picture

Let's now test everything you've done.

  1. Click on the Interactions tab in the lower-left corner of the window
  2. Type these 3 lines in the interactions pane (be sure to change the username "monge" to yours!!). If you copy/paste these three lines, be sure to increase the width of your Internet Browser window to make sure there are no line breaks.
    FileChooser.setMediaPath("C:/Documents and Settings/monge/My Documents/MyProjects/CECS174/mediasources/"); 
    p = new Picture("eiffel.jpg"); 
    p.show();
    Ask for help if you get an error in any of the above steps. If done correctly, you will get a window displaying a picture of the Eiffel Tower in Paris. The figure below shows the code typed in and the resulting popup window.

Quit DrJava

  1. To quit DrJava... select "Quit" from the File menu.

Great job!

You're ready to start programming! You may go back to the guide on getting started in the CECS Labs. This link should take you back.

Programming Resources