CSE 142: Computer Programming I, Autumn 2007 |
CSE Home | About Us Search Contact Info |
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
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.
Accept the License Agreement and choose the "Windows Offline Installation, Multi-language" file: jdk-6u3-windows-i586-p.exe
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.
You can choose all the default options during installation.
2) Download DrJava editor
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.
- NOTE: If you use the new Windows Vista, you may need to choose to "Download Jar File" rather than "Download Windows App."
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:
- "tools.jar" message:
When you run DrJava for the first time, you may receive an error message about not being able to find a "tools.jar" file. The box asks if you would like to browse for the file. Click Yes. In the file browse window that appears, browse to the following folder:C:\Program Files\java\jdk1.6.0\lib
From that folder, select the file "tools.jar" and choose OK.
- "No compiler is available" message:
You see a "no compiler is available" message when you try to compile programs in DrJava:
File: C:\Documents and Settings\timmy\Hello.java [line: (no source location)] Error: No compiler is available.If you see this, DrJava has not found your JDK correctly. You may need to fix the tools.jar problem as described above, or possibly you do not have the JDK installed properly. A common student mistake is to download the JDK installation file, but to forget to actually run it to install the JDK. Please make sure that you have both downloaded and installed the JDK successfully before running DrJava. Another common reason for this problem is when the student downloads the wrong file for the JDK instead of the one described above. Sun has several JDK download links, and you should make sure you chose the right one (usually the first option).
- "MSVCR71.dll" message:
When you run DrJava, you may receive an error message complaining about a missing "MSVCR71.dll" file. This file comes with Java JDK, but for some reason JDK can't always find it. You can fix the problem by copying MSVCR71.dll from JDK's folder to the C:\WINDOWS\SYSTEM32 folder. Open up My Computer and navigate to the folder below:C:\Program Files\java\jdk1.6.0\bin
From that folder, select the file "MSVCR71.dll" (it may just say "MSVCR71" depending on your Windows settings), right-click it, and choose Copy. Now navigate in My Computer to the folder C:\WINDOWS\SYSTEM32 and choose Edit, Paste. This should copy the MSVCR71.dll to this folder. Now try to run DrJava again.
- "Interpreter JVM exited before registering" message:
When you run DrJava, you may receive an error message such as:
java.lang.IllegalStateException: Interpreter JVM exited before registering, status: 0 at edu.rice.cs.drjava.model.repl.newjvm.MainJVM.slaveQuitDuringStartup(MainJVM.java:689) at edu.rice.cs.util.newjvm.AbstractMasterJVM$1.run(AbstractMasterJVM.java:205)This message can often result from anti-virus or security software that is blocking DrJava from functioning. If your security software pops up a warning about DrJava, tell it to allow DrJava to proceed. (Newer versions of Windows have similar security warnings about allowing DrJava to connect; if Windows pops up a security warning about DrJava, click the option to allow DrJava to proceed.)
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
There is a Mac version of DrJava, available from the same DrJava web site by clicking the button labeled "Download Mac OS X App".
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.binRunning 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
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
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.
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.txtThere 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