UW CSE logo uw

CSE 142: Computer Programming I, Autumn 2007

arrow CSE Home arrow About Us arrow Search arrow Contact Info

Working at Home

(last updated Wed Oct 3 2007)

You will need to install, at most, two pieces of software: The Java Development Kit (JDK) and the DrJava editor. The directions differ based on your operating system.

Windows ... (common problems)
Mac
Linux
 
Useful Options for DrJava and Your Operating System
Comparing Text Files


Windows users:

1) Install Java Development Kit (JDK)

http://java.sun.com/javase/downloads/index.jsp

Follow the above link and click the "Download" button next to the first option, "JDK 6 Update 3".
(Not the "with NetBeans" link or the "with Java EE" link or others below).

Note: Sun updates JDK frequently; right now the page's first download option is some kind of "Get Early Access to Jave SE 6 Update 5" crap. Don't download that. Use the Download link below that. download JDK

Accept the License Agreement and choose the "Windows Offline Installation, Multi-language" file: jdk-6u3-windows-i586-p.exe
download JDK
download JDK

download JDK

Once you have finished downloading this file to your Desktop, you must install JDK on your system. Do this by double-clicking the JDK installer file on the desktop.
download JDK
download JDK

You can choose all the default options during installation.
 

2) Download DrJava editor

http://drjava.net/

Find the section labeled "Current Stable Release," then click the button labeled "Download Windows App." You will be taken to a download page that lists many Hosts and Locations. Pick one of the locations in North America and press its Download link on the right side of the page. Click the link to download the file, whose name will be drjava-stable-20070828-1759.exe. Save the file to your Desktop or another convenient location.

Once the file is downloaded, examine your desktop and double-click the drjava-stable-20070828-1759 file to run DrJava. (DrJava does not need to be installed; the file you download is the actual DrJava program.)
 

COMMON PROBLEMS WITH INSTALLATION:

 


Mac:

1) Install Java Development Kit (JDK)

Macs with the OS X operating system will have Java available automatically, but you may need to install the latest Mac version of JDK, version 5.0. Some newer Macs (purchased within the last 6 months or so) already have this software, but older ones do not. If you have a fairly new Mac, you may want to try to skip to Step 2 and see if DrJava works, and if not, come back to this step.

If your Mac doesn't have Java installed already, you can go to this web page to download it:

http://developer.apple.com/java/download/

You probably want to choose the link that says Java for Mac OS X 10.4, Release 5 (Universal). If you have an older version of OS X, you may need to choose one of the other links. You can see your OS X version by clicking the Apple icon on the top-left of your screen and choosing "About this Mac."

Once you've downloaded the file, double-click it on your desktop to install it.

2) Download DrJava editor

http://drjava.net/

There is a Mac version of DrJava, available from the same DrJava web site by clicking the button labeled "Download Mac OS X App".

 


Linux:

It's tougher to give an installation guide for Linux because of the large variety of different distributions and architectures. Here is a rough guide that will work for many distributions such as Ubuntu.

1) Install Java Development Kit (JDK)

http://java.sun.com/javase/downloads/index.jsp

Follow the above link and click the "Download" button next to the "JDK 6.0 Update 3". (NOT the "with NetBeans 5.0" link or the "with Java EE" link or others). Accept the License Agreement and choose the "Linux self-extracting file" file:

jdk-6u2-linux-i586.bin

(If you use a Linux distribution that supports RPM packages such as Fedora Core, you may wish to use the "Linux RPM in self-extracting file" package.)

Once you have finished downloading the JDK .bin file, open a terminal window and execute the file. You may have to give execution permissions to the file:

chmod +x jdk-6u2-linux-i586.bin
./jdk-6u2-linux-i586.bin

Running the .bin file extracts the JDK contents. Move these to a directory of your choice. (The rest of this tutorial assumes you have moved the JDK to /usr/lib/jdk/ .)

After installing Java, you will probably wish to add Java's directory to your PATH setting, so that you can run Java commands from your terminal. To do so, edit the file .bashrc in your home directory and add the following lines to the end of it:

export PATH=/usr/lib/jdk/bin:$PATH
export CLASSPATH=.

You should close your terminal and open a new one for the PATH changes to take effect.
 

2) Download DrJava editor

http://drjava.net/

Find the section labeled "Current Stable Release," then click the button labeled "Download Jar File." Choose a download mirror and save the file named drjava-stable-20070828-1759.jar to a convenient location.

Once the file is downloaded, open a terminal window, change directory to the one that contains the DrJava Jar file, and type the following:

java -jar drjava-stable-20070828-1759.jar

 


Useful Options for DrJava and Your Operating System

DrJava - Enable Line Numbers:

If you'd like DrJava to show numbers at the front of each line of your source code, click the following in the main menu of DrJava:

Edit, Preferences...

Now a Preferences window appears. On the left side of this window, click the text Display Options. Some new options will appear on the right. Check the checkbox labeled Show All Line Numbers. Press OK.
 


 

DrJava - Increase Indenting to 4:

The default amount of indentation (when you press Tab) in DrJava is 2 spaces. Many programmers prefer an indentation level of 4 spaces to make the code easier to read. If you'd like to change this value, in DrJava open the Preferences window as described above. On the left side of the Preferences window, click the text Miscellaneous. Some new options will appear on the right. Type your desired indentation amount into the text box labeled Indent Level. Press OK.
 


 

DrJava - Disable Backup Files (CAUTION):

By default DrJava creates a backup file of your program with the extension .java~ every time you save it. If you'd like to change this value, in DrJava open the Preferences window as described above. On the left side of the Preferences window, click the text Miscellaneous. Some new options will appear on the right. Uncheck the checkbox labeled Keep Emacs-style Backup Files. Press OK.

(CAUTION: These backups can be helpful to protect you from accidentally deleting or damaging your program. Only disable them if you are sure you do not want or need this protection.)

 

Enable File Extensions in Windows:

By default, Windows does not show extensions of certain types of files. This can lead to confusion because you may not know which file is your .java program and which is your .class compiled file.

If you'd like to change this value, open My Computer. From the window's main menu, click the following:

Tools, Folder Options...

A Folder Options window will appear. Click the tab labeled View, then find the checkbox labeled Hide extensions for known file types. Uncheck it. Press OK.

Now all files should show their extensions in Windows.

 


Comparing Text Files:

The following programs may also be useful to help you compare text files for differences, such as to compare your program's output against the expected homework output.

To make your Java program's output into a text file, run your program in DrJava, then copy and paste its output from DrJava into a text editor and save the file as a .txt text document.

WinDiff (Windows)

http://www.grigsoft.com/download-windiff.htm

Follow the above link and download the program as a ZIP archive. Inside the archive is the windiff.exe program to execute. To use WinDiff, run the program and click File, Compare Files... and browse to the two text files to compare.

diff (Mac/Linux)

Mac OS X and Linux operating systems contain a command named diff that can compare two text files and output the differences between them. The diff command is executed from a terminal window. If you use a Mac and do not know how to use the Terminal, consider reading a tutorial such as the following:

http://www.macdevcenter.com/pub/a/mac/2001/12/14/terminal_one.html

Within the terminal, the diff command is invoked with two command-line arguments: the names of the files to compare. For example:

diff file1.txt file2.txt

There are several tutorials on the use of the diff command, such as:

http://www.cis.fiu.edu/support/unix/unix-tutorial/util-diff-comp.html