Norm Matloff's Introduction to the BlueJ Java IDE

BlueJ is a small integrated development environment (IDE) for Java programming, especially for beginners. It is similar to other IDEs, in that it consists of a project manager, editor, class browser, runtime monitor and a debugger. It is best suited to small projects. Its virtues are:

Some drawbacks:

BlueJ is meant for general users, but is designed particular with student usage in mind. This implies a bit of loss in flexibility and a lack of some bells and whistles one might find in other IDEs, but the simplicity of use and the small size

Contents of this Web page:

(A small amount of the material here is OS-dependent. We are assuming a UNIX environment here; see the BlueJ home page for direction for Windows systems.)

Where to get BlueJ:

Download from the BlueJ home page. Note that you cannot simply click on the highlighted file; see the instructions on the site.

How to install it:

Make sure you have the Java JDK package installed on your system. For the current version of BlueJ, 1.1.4, you need Sun JDK 1.3. Obtain it at JavaSoft.

The package is self-installing. Simply type

java -jar bluej-111.jar

(replace the .jar file in this command if you obtain a newer version than 1.11). Then add the BlueJ directory (the one containing the executable file, bluej) to your search path.

Starting it up:

Simply type


If you are running JDK 1.3.1 on Linux, you may get a segmentation error. If so, type the following and then try again:

limit stacksize 2048
Or try adding the -classic option in the Java run line at the end of the bluej script.

At this point, the BlueJ console window will appear.

How to create a project:

A project in many IDEs today typically loosely corresponds to a Makefile. In BlueJ a project is a directory containing a bluej.pkg file.

To create a new project from scratch, i.e. with no Java code written yet, choose Project then New from the BlueJ console. Whatever name you give the project, a directory will be created of that name, and its contents initialized to a couple of supporting files. You can then use the BlueJ editor to create your Java code files. (BlueJ will actually put in a fake Java code file for you; simply remove all the contents before typing your real code. This was apparently put in for student use; if you find it annoying, remove the given file in the lib subdirectory of your BlueJ directory.)

If you already have Java code files in a given directory, say abc, you can convert that directory to BlueJ project as follows. Again choose Project in the console window, and select Open Non-BlueJ. You will then be able to convert abc to a BlueJ project (and from then on, choose Project and Open from the console whenever you wish to work on that project). Note: After creating a new project in this way, click on Compile, then click on Project and Save, then click on Project and Close. Then re-open the project (it's now a BlueJ project) for whatever work you want to do.

How to use the editor:

Click on New Class to make a new class file. The editor window will pop up, and you can start typing.

To edit existing files, look at the icons for the classes in the console. Click on the icon for the class you want, using the right mouse button and choosing Edit Implementation.

The editor is simple, without fancy features, but quite usable and visually appealing.

Note that when you click Compile, the editor automatically saves the changes you made to the file.

How to execute a Java class:

Right-click on the console icon of the class you want to execute, and choose the item you wish to execute, typically main(). It may not be main(), though. By allowing the user to execute any class method on its own, it may be easier to debug a method.

If the class has arguments, a call window will pop up for the user to fill in with the arguments. In the case of main, these are the command-line arguments. Recall that these comprise an array of strings. BlueJ will then expect you to input them as such. If for example the command line would have been

12 5 8

if the program had been run in standalone mode, BlueJ expects us to fill in the window with

{"12", "5", "8"}

i.e. initializing the array to consist of the three strings shown. (Note that this notation, using { , , , }, is borrowed from the form in which Java has a programmer auto-initialize arrays.)

If your program has output to the screen, a terminal window will pop up for this (and for input from the keyboard).

How to use the debugger:

If the file is not already in an editing window, bring one up now.

You can set a breakpoint by clicking next to the desired line, in the separate breakpoint column. A little stop sign will appear there. The operation toggles, i.e. clicking there again will cancel the breakpoint.)

If the breakpoint column is filled in with gray, that means the file needs compiling; either there is no .class file for it, or the .java source file is newer than the .class file. You won't be allowed to set breakpoints until you compile.

Apparently, if a given .java file contains a "main" class and one or more others, BlueJ will not allow you to set breakpoints in the latter files. So, put each class in a separate .java file

Start execution of the program as explained above. A debugger window will pop up, and the program will stop at the first breakpoint it encounters. The debugger window contains the usual single-step/continue operations. (Note: In some cases you may need to reactivate the thread, usually main(), by clicking it in the debugger window; you will be warned of this by a "No active thread" message in the shell window from which you invoked BlueJ.)

The debugger shows the call stack, and instance/local variables.

If you wish to terminate execution of the program prematurely, click on Terminate in the debugger window. Note that the editor will not allow you to make changes and recompile until the program comes to a complete stop; this includes other programs from another invocation of BlueJ which you have running.