Com S 100J Introduction to Computer Programming Grade: letter or S/U Spring 2005
655-085 TR 09:05 Kimball B11 Instructor: David Gries 4 credits
655-276 TR 11:15 Olin 255 Newsgroup: cornell.class.cs100j

About email
Academic Excellence Workshop
Academic integrity
Exams & grades
Handouts, general
Staff info
Times & places
Email Gries

The programming environment used in CS100J is DrJava, a free "Integrated Development Environment (IDE).

DrJava will be used in class to demonstrate programming in Java. In addition, you should download DrJava onto your computer and use it heavily in practicing programming in Java.

DrJava was developed by Professor Corky Cartwright at Rice University.

Both DrJava and Codewarrior are installed on CIT's computers.

Table of contents


You need a Java virtual machine

DrJava requires a Java 2 v1.3 (or later) virtual machine and software development kit (SDK). If you are using a PC running a version of Windows, you may not have it. DO NOT TRY TO INSTALL THIS STUFF UNLESS YOU ARE POSITIVE YOU DON'T HAVE IT ON YOUR COMPUTER YET! For PC's, the following site seems to automatically check whether the basic Java runtime system is available on your computer:

If you have a Macintosh with Mac OS X, you almost certainly have the Java SDK installed already, and you don't have to download the SDK.

One virtual machine/SDK is Sun's J2SE SDK --follow that link and select "DOWNLOAD" from the right-hand column that appears. Warning: this is a big download! If you want to download the Java API specifications, look at the very bottom of that page for "J2SE v 1.4.1 Documentation".

Can't execute jar files

If you cannot double-click on a jar file to start it running, or if you cannot execute any of the commands java, javac, javadoc, or jar, you probably have not set your path correctly. We explain this for Windows 2000; older windows systems are similar.

Your system contains a variable that lists directories with executable files in them. Type "path" in a command-line window. The line that is printed contains path names separated by semicolons. For example, one path name may be:


There should be a path that looks like this: C:\j2sdk1.4.1_02\bin. This is a directory called bin inside the directory where you installed the sdk. It may be different on your computer. If such a path is not there, you have to add it. Bring up the help in your Windows system, open the index, and look for "path". There, you will find instructions on appending another directory to variable path. It may be something like this (but read the instructions):
path  %path%;C:\j2sdk1.4.1_02\bin

Downloading DrJava

Download DrJava (by clicking the link). The page will show you several versions of DrJava. Get the latest, which at the time of this writing is the beta release drjava-beta-20041215.jar. Note that DrJava won't run unless you have a Java 2 v1.3 (or later) virtual machine already installed.

Warning: you may get a dialog saying something about a "JAR archive security check". If you do, just right-click on the DrJava download link and select "Save Link As" (or the equivalent in your browser).

We know that all this setup can be annoying, but you have to do it only once!

A common DrJava problem: finding tools.jar

Question: I downloaded Sun's J2SE SDK and DrJava. When it came to actually running DrJava, the following window kept popping up even though somehow DrJava still managed to run without me finding the file --what should I do?:

Compiler not found. The file you chose did not appear to contain the compiler. Would you like to pick again? The compiler is generally located in 'tools.jar', in 'lib' subdirectory under your JDK installation director. (If you say 'No', DrJava will be unable to compile programs.)

Answer: First, make sure you installed the Java SDK, not the JRE. (See above.)

Now you need to find a file called "tools.jar". If you're using Windows, then when you installed the SDK, you probably put it in "Program Files". The name of the Java folder is probably something like "j2sdk1.4.0_01"; look inside that for a directory called "lib", and inside "lib" look for "tools.jar".

Running DrJava

There are several ways to run DrJava:

  • From the command line, you can type java -jar drjava-beta-20041215.jar
  • On many platforms, you can simply double-click the jar file to start DrJava.
  • On OS X or Windows, download the appropriate application. You can then run DrJava as a normal application.

Documentation --how to use DrJava

The demos given in class and in the demo sessions should help, if you take notes.

Second, information on using DrJava is in Appendix I of the course text and in Chapter 19 Chapter 19 of the accompanying CD ProgramLive. Watch the ProgramLive lectures! They are short and informative.

Third, here is documention on using DrJava on the web.

Wrong-version error.

Do you get a message that looks like this?

Error: cannot access javax.swing.JFrame
bad class file: C:\Program Files\Java\jre1.5.0\lib\rt.jar(javax/swing/JFrame.class)
class file has wrong version 49.0, should be 48.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

It may mean that your computer has two different systems on it and is an inconsistent state. If your computer has jre5.0, then it cannot use SDK 4.7. Uninstall SDK4.7 and download JDK 5.0 and use its tools.jar