The Source for Java Technology Collaboration
User: Password:



   

Java Tech: The Sweet Song of the BlueJ, Part 1 Java Tech: The Sweet Song of the BlueJ, Part 1

by Jeff Friesen
07/21/2005

Contents
What is BlueJ?
Installing BlueJ
Touring the GUI
BlueJ by Example
Conclusion
Resources
Answers to Previous Homework

I recently discovered a Java product called BlueJ. This product, symbolized by the image of a blue jay, is used to teach object orientation to students. In contrast to the harsh-sounding blue jay (which happens to be a member of the crow family), BlueJ is anything but harsh. This simple yet powerful product presents a short learning curve, which is ideal for students.

Welcome to the first installment in a two-part series that explores BlueJ. This article introduces the product, reveals its reason for being (Java instructors, take note), shows how to install BlueJ, and takes a tour of BlueJ's GUI. The article climaxes with an example that illustrates several BlueJ features.

Note: This series is based on BlueJ version 2.0.4 and J2SE 5.0 running on the Windows 98 SE platform.

What is BlueJ?

BlueJ is an integrated Java environment that has been designed to teach object orientation with the Java language. BlueJ is based on the earlier Blue system, a programming language and integrated environment. BlueJ, an almost identical environment to Blue, replaces the Blue language with Java.

BlueJ provides a project manager and an editor. It relies upon an installed Java 2 Standard Edition software development kit for compilation, debugging, and other facilities. Tools are fully integrated in BlueJ: compilation from within the editor, compiler error message display in the editor, setting breakpoints in the editor, and so on.

BlueJ was developed to provide an appropriate environment for teaching object-orientation concepts to students. Unlike many other environments, BlueJ emphasizes classes and objects as its basic units of interaction. Students are not required to learn Java's public static void main(String [] args) method, or worry about input/output prior to creating and interacting with objects: BlueJ takes care of those tasks on behalf of the student. Regarding main(), BlueJ's developers believe that introducing students to that method first is problematic. Why begin teaching object orientation by introducing a method that is essentially procedural? The BlueJ team discovered that this approach only confuses students, who must also learn about arrays right from the start. They found that it was better to first focus on classes and objects, and introduce the main() method, input/output, and arrays after the student becomes more comfortable with Java.

BlueJ is easy to use; students can begin working with BlueJ without needing a lengthy introduction to the environment. BlueJ lets students visually and interactively create classes and interconnect them. Students can then instantiate objects from those classes, invoke methods, specify arguments to those methods via dialogs, view return values via dialogs, and visually inspect object state. This product is freely available, a benefit to students who cannot afford costly licenses (BlueJ cannot be sold for profit).

BlueJ originated at Monash University in Melbourne, Australia. It is currently being maintained as a joint project among Deakin University, the University of Kent, and the University of Southern Denmark.

Installing BlueJ

BlueJ is available for Windows, the Mac OS, Linux/Unix, and other operating systems. Regardless of the operating system, J2SE 1.4 or higher must be installed. Because BlueJ relies on tools made available via the J2SE SDK, installing only the J2SE JRE is not sufficient.

For Windows platforms, the BlueJ distribution is contained in file bluejsetup-xxx.exe, where xxx is a version number. For example, the BlueJ version 2.0.4 distribution is contained in bluejsetup-204.exe.

The installer portion of the Windows BlueJ distribution lets you select the directory into which to install BlueJ. It also presents the option to install a shortcut into the Start menu and on the desktop. When the installer completes, you'll find bluej.exe in the installation directory. This program starts BlueJ.

When BlueJ first runs, it searches for a J2SE 1.4 or higher SDK. If it finds more than one version, BlueJ presents its BlueJ Launcher dialog box, which lets you select the desired SDK. If BlueJ isn't able to find a suitable SDK, this dialog box lets you search for the SDK.

After installing BlueJ with a specific J2SE SDK, you can change to another SDK version by including bluej.exe's /select command-line option the next time you run that program. In response, the BlueJ Launcher dialog box appears.

Note: You can install different versions of BlueJ and associate a different installed version of the J2SE SDK with each BlueJ version. For example, you can associate BlueJ 2.0.1 with J2SE 1.4.2 and associate BlueJ 2.0.4 with J2SE 5.0.

Touring the GUI

BlueJ manages Java-based projects. The current project is revealed in its main window. In Figure 1, the main window presents people--an example project that ships with BlueJ--as the current project.

BlueJ's main window identifies the people project
Figure 1: BlueJ's main window identifies the people project

The main window divides into five sections: menu bar, project tool bar, class diagram, object bench, and message area. The menu bar offers Project, Edit, Tools, View, and Help menus:

  • Project provides menu items that create a new project, open an existing project, save the current project, quit BlueJ, and more. For example, I selected Open Project... to open the example people project shown in Figure 1.
  • Edit provides menu items that introduce new classes into the current project, introduce new dependencies between classes, remove classes and dependencies, and more.
  • Tools provides menu items that compile all uncompiled classes in the current project, compile only the selected class, set preferences, and so on.
  • View provides menu items that show or hide dependencies, show or hide the debugger, and more.
  • Help provides menu items that show an about box, check for a new version of BlueJ, take you to a BlueJ tutorial, and so forth.

The project tool bar, located on the left side of the main window and just below the menu bar, consists of four buttons that, respectively, introduce new classes into the current project, introduce "extends" or "implements" dependencies between classes, introduce "uses" dependencies between classes (for example, a Library class uses a Book class by implementing an array of Book objects), and compile the entire project.

The class diagram, on the right side of the project tool bar, graphically displays the current project. It presents a project description note icon, class icons, and dependency arrows:

  • The project description note icon (in the upper-left corner) describes the current project. When creating a new project, double-click the icon to enter information about the project, including its author and how to run the project. This helps others understand your project and how to work with it.
  • Class icons identify classes and interfaces (which BlueJ regards as a special kind of class). The upper portion of the icon presents the class name. Abstract classes and interfaces are revealed by <<abstract>> or <<interface>> just above the name. The icon of the current class (that is, the class that will be compiled when you choose Compile Selected from the Tools menu) is identified with a darker border and a pair of diagonal stripes in the lower-right corner of its icon. If a class has not been compiled, the entire lower-right area consists of diagonal stripes.
  • Dependency arrows reveal relationships between classes. Solid lines with hollow arrow heads indicate either "extends" relationships (where the arrow points to the superclass) or "implements" relationships (where the arrow points to the interface). In Figure 1, two solid lines reveal "extends" relationships between Staff and Person, and between Student and Person. Person is the superclass. Dashed lines indicate "uses" relationships. Each class pointed to by the arrow is used by the class on the other end of the dashed line. For example, Figure 1 shows that Person is used by Database. In other words, Database references Person in its source code.

Right-click the mouse on a class icon and a pop-up menu appears. This menu offers various options, including compilation. If a class's source code has not been compiled, you can compile that source code by choosing Compile from the pop-up menu.

The object bench, toward the bottom of the main window, identifies various objects that have been created. Objects are created by right-clicking a compiled class's icon, selecting one of the "new" constructor menu items from the pop-up menu, and responding to dialogs that let you name the object and (if appropriate) pass arguments to the constructor. Figure 1 shows a single staff1 object icon on the object bench. The object represented by that icon was created by choosing the top menu item from the pop-up menu.

A single-line message area appears below the object bench. As you work with BlueJ, various messages appear in this area.

Pages: 1, 2, 3, 4, 5, 6

Next Page » 

View all java.net Articles.

 Feed java.net RSS Feeds