Previous Up

5  Configuring DrJava and using the Command Prompt

5.1  Basic configuration requirement

Set the indentation level in DrJava to 4 spaces, by selecting Preferences -> Miscellaneous -> Indent Level -> 4. (Now you will be able to properly format your homework by using the indent key.)

5.2  Basic configuration suggestions

Display line numbers, by selecting Edit -> Preferences -> Display Options -> Show All Line Numbers.

Deactivate automatic updates, by selecting Edit -> Preferences -> Notifications -> Check for new versions -> none

Turn off “emacs style” backups (backup files with names that end in tilde), by unchecking Preferences -> Miscellaneous -> Keep emacs-style Backup Files.

5.3  Configuring DrJava to use Sedgewick and Wayne’s standard libraries

If you’re unsure, please wait until we do this in lab.

DrJava comes with many standard libraries built in. But in this course we also need the standard library provided by Sedgewick and Wayne, which adds a few convenient features to those libraries. We need this starting in section 1.5 of the textbook.

Note: You can also download stdlib.jar from the booksite, specifically here.

Important note: Section 1.5 also discusses I/O redirection and piping, for which you will need to learn how to use the “shell” (also known as “terminal” or “command prompt”). We will cover this in lab at a later date.

5.4  Configuring your computer to use Java stand-alone at a Command Prompt

Important note: these are PRELIMINARY instructions, as an aid to walk through the process during lab. Please wait until lab unless you are quite confident about system administration for your computer.

5.4.1  Instructions for Windows 7

Add the Java compiler to your PATH variable:
Add StdLib to your CLASSPATH variable:
Check that everything is working:

5.4.2  Instructions for Mac OS/X

Using DrJava or another text edit, edit the file /Users/username/.bashrc and add one line near the beginning of the file:

    export CLASSPATH=.:/Users/username/introcs/

If the file doesn’t exist, create a new one.

Close the Terminal and open a new one. See the Windows instructions for how to check that everything is working. If it does not work, in addition, try repeating the same instructions with the file /Users/username/.bash_profile

5.5  Using the Command Prompt

Preliminary instructions – we will explore this in lab.

5.5.1  For Windows 7:

Pin the Command Prompt to your start menu:
Double-check that Java is set up properly:
Open a command prompt and enter “java -version”. You should see something like this.
C:\Users\username>java -version
java version "1.6.0_27"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0_27-b07)
Java HotSpot(TM) Client VM (build 1.6.0_27-b13, mixed mode, sharing)
Any version numbered like 1.6.any is ok.
Learn a few commands:
Here is a short tutorial on the Windows command prompt. It assumes that you have installed your course work in a directory named C:\introcs.

Note: We can now compile programs at the command prompt, but it is preferable to use DrJava. Pay attention to where you are saving and compiling, to avoid frustration about which copy of your program is running.

5.5.2  For Mac OS/X:

Open Applications -> Utilities -> Terminal

It works similarly to the command prompt in Windows but some commands have different names. Try reading the short tutorial on the Windows command prompt but when you try the commands yourself use these equivalents:

winmac
dirls(list directory)
movemv
copycp
cdcd(change current directory)
moremore
exitexit
javajava
javacjavac

In OS/X, directory paths are written with forward/slash rather than backward\slash as in Windows.

CS 115 Fall 2011          Revision: 1.12 , Date: 2011/12/03 18:57:20
Previous Up