BlueJ is a free Java environment available from Monash University. BlueJ requires a Java 2 runtime, so you need to install the JDK first before installing BlueJ. BlueJ is written in Java and runs on any platform with a Java 2 runtime, such as Linux, Solaris, Windows, or Mac OS X.

BlueJ is a wonderful environment that makes you think about objects and object-oriented programming. It also contains an excellent, easy to learn debugger. You can use BlueJ to run regular Java programs, but to make the best use of the environment, it is best if you reorganize the programs.

General Remarks

In BlueJ, you should have a subdirectory for each program. This is different from the way that the book code is distributed, with one subdirectory per chapter. Simply make a new subdirectory every time you write or test a new program, and copy the source files that you want into that directory.

To start BlueJ, open a command shell and type a command such as

cd \bluej

On Linux/Unix, enter a command such as

cd /usr/local/bluej

The details depend on your software installation.

Then select Package -> Open Non BlueJ from the menu.

Open Non BlueJ menu
select the subdirectory containing your files. Caution: You want to select that directory, and not enter the directory. Highlight the directory name and then click the "Open in BlueJ" button.

Now you see the class or classes that BlueJ discovered in the selected subdirectory.

{short description of image}

Click the "Compile" button to compile all classes. 

You can use BlueJ to simply compile and run all examples in the book. To run an application, right-click on the class with the main method and run main with the default value of null for the args parameter. To run an applet, right-click on the applet class and select "Run applet." However, if you just use BlueJ as a program launcher, you do not take full advantage of its capabilities.

The biggest difference between BlueJ and traditional development environments is that BlueJ isn't concerned with running programs. Instead, you investigate objects.

To instantiate an object, right-click on the class and select an appropriate constructor.

The object is created on the "object workbench" below the class display. To investigate the object, right-click on it and start calling methods. (You can call static methods without instantiating the class, by right-clicking on the class.)

To make effective use of BlueJ, you want to eliminate the very un-object-oriented public static void main and replace it with other means. For example, see the BlueJ version of below.

You can simply download a zip file with all the converted examples, ready for use in BlueJ.

Below you will find the rationale behind the conversions.

Chapter 1

Chapter 2

Chapter 3

Chapter 4

The programs in this chapter are all applets and don't need to be modifed. To run an applet, simply right-click on the class file and choose "Run Applet".

Chapter 5

Save the classes Earthquake and TaxReturn in separate files and discard the driver programs.

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Discard the AccountTest driver class and place the four account classes in a single directory. Investigate the classes with BlueJ.

Chapter 10

Chapter 11

Chapter 12

Move the calls to setTitle and show inside the frame constructor. Note that the call to show must be the last line of the constructor. Remove the main method and the window closer. Split the program into multiple files, one for each class.

Chapter 13

Chapter 14

Chapter 15

The biggest problem is that you can't put the int[] array that the ArrayUtil.randomIntArray method returns onto the object workbench. Conceptually, that is unfortunate because after all arrays are objects. To overcome that, I made wrappers IntArray and StringArray.

Chapter 16

Break up into one class per file.