M/F 2:30-3:20   
in G01 Gates Hall

CS 1130: Transition to OO Programming

Spring 2016

DrJava

The Java programming environment used in CS 1130 is DrJava, a free Integrated Development Environment (IDE). DrJava was developed by Professor Corky Cartwright at Rice University, who has developed a number of IDE intended for beginning students. Dr Java is installed in the ACCEL lab and on most on computers in CIT labs. However, you will probably want it on your own computer as well.

If you have problems, and if you have a laptop, the best thing to do is to bring it in to someone to look at. Any of the course staff or consultants can help you with this. If you cannot bring in your computer, we have provided you with some instructions below. If you are having difficulty with these instructions, please email TA ??? <@cornell.edu>.


Installing DrJava

Table of Contents


Installing a Virtual Machine

DrJava is just a tool to make writing Java source code easier; it does not actually provide you with a copy of the Java software development kit (JDK). So before you do anything else, you need to make sure that you have a copy of (the most recent) JDK.

If you have a Macintosh with Mac OS X, Java should already be installed and you do not have to do anything. Furthermore, as long as you have run the latest Software Update, your version of Java should be the correct one (Java 6 Update 34).

On the other hand, if you are using a PC running a version of Windows, chances are that you don't have the JDK yet. Therefore, you will need to download it from the Java website. If you follow the link, you will see that we are using the JDK 6 Update 34. This is not the most recent version of Java (version 7 is more recent). However, it is the most recent version that is guaranteed to work with DrJava. If you run any other version, we cannot guarantee that everything will work correctly. You should choose the version that is appropriate for your version of Windows; this means x64 if you are running 64-bit Windows and x86 if you are running 32-bit Windows.

You should read the instructions when installing the Java platform. One of the things that you will notice is the the download from Oracle gives you both the the Java Runtime Environment (JRE) AND the Java Development Kit (JDK). The Java Runtime Environment allows you to run Java programs that have already been created (by you or someone else). For example, you need the JRE to run any Java programs that are contained in "jar files". The Java Development Kit, on the other hand, allows you to "compile" Java programs — this means that it translate them into a "machine language" — so they can be run by the Java Runtime Environment.


Downloading DrJava

DrJava is continually being updated. For this class, we will use the most stable version (not the untested beta version!), which is currently version 20100913-r5387. The easiest thing to do is to download the version that we provide you. This version has been thoroughly tested with Java 6 update 34, and so is the best one to use.

Alternatively, you can download the latest version of DrJava from the official web page. In addition to the Jar file (which we provide), this site also provides native applications for both Windows and Macintosh. It is fine for you to use the native applications instead of the Jar file; however, you must choose the stable version of DrJava and not the Beta version.

Warning: When downloading, 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).


Running DrJava

There are several ways to run DrJava. From any command line (on Windows, Macintosh, or Linux), you can type the following:

java -jar drjava-stable-20120818-r5686.jar

We recommend doing this the first time that you launch DrJava, as the command line will display a lot of helpful error messages if anything goes wrong.

Once you are sure that this works, you are free to use a more graphical approach. On most platforms, simply double-clicking the jar file should start DrJava. However, sometimes double-clicking does not work on Windows machines. The problem may be that some other application has "stolen" the right to be executed when the jar file is doubleclicked. If you are experiencing this problem, visit the JarFix site and see whether it can solve the problem.

If this all sounds too complicated, you can just download the native application for Windows or Macintosh and use that instead.


DrJava Documentation

Once you finally have it running, DrJava is pretty easy to use. The demos given in class and in the demo sessions should help a lot, if you take notes.

If you need more information, help with using DrJava is in Appendix I of the course text and in Chapter 19 of the accompanying CD ProgramLive.

If all else fails, there is documention on using DrJava available on the web.


Troubleshooting: Finding tools.jar

On Windows machines, we have sometimes seen an error that the the system cannot find a file called tools.jar. If this happens, you need to select the correct location of that file. It is typically in a folder like it is in some place like

C:\Program Files\Java\jdk1.6.0_29\lib\tools.jar

However, the exact folder may differ depending on your version of Java. You can also use a desktop tool to search for this file on your computer.

If you did not set the correct path for the file tools.jar at installation time, set it after installation by going through DrJava's Preferences option. To do so, follow these menu items:

Edit / Preferences / Resource Locations / Tools.jar Location

Then type or browse to the correct location.


Troubleshooting: 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\jdk1.6.0_29\lib\rt.jar(javax/swing/JFrame.class)
class file has wrong version 50.0, should be 48.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

This often means that your computer has two different versions of Java and is confused. If your computer has a copy of Java version 5 or newer, then it cannot use Java version 4 or older (there was a major change with Java version 5 that broke some backwards compatibility). You should uninstall the older version of Java if you know how; otherwise, you should immediately ask either the course staff or consultants for help.