You are on page 1of 44

UNDERGRADUATE COMPUTING

M255 Object-oriented programming with Java

M255

Software Guide – Installation

This guide covers the installation and basic use of the BlueJ IDE and M255 course software.

Copyright © 2009 The Open University WEB 00718 7


4.1
Contents
1 Introduction 3

1.1 The course software 3

1.2 Using this document 3

2 Installing the course software 4

3 The Amphibian Worlds and Accounts World applications 8

3.1 Amphibian Worlds 8

3.2 Accounts World 9

4 Launching BlueJ 10

4.1 Changing the version of Java used by BlueJ 10

4.2 Problem launching BlueJ? 11

5 Using BlueJ 12

5.1 Opening projects 12

5.2 Opening an OUWorkspace 13

5.3 Opening Amphibian Worlds and Accounts World from within BlueJ 13

5.4 Creating a new project 14

5.5 Adding a class to a project 14

5.6 Compiling a class 15

5.7 Deleting a class from a project 15

5.8 Saving a BlueJ project 15

5.9 Copying a BlueJ project 15

5.10 Resetting BlueJ 16

5.11 BlueJ Help 17

5.12 Generating project documentation 18

6 Using the OUWorkspace 20

6.1 Executing statements 21

6.2 The Inspector window 22

6.3 Behaviour of the OUWorkspace when a class is compiled 23

6.4 Resetting the OUWorkspace using the F12 key 23

6.5 OUWorkspace menu options 24

7 Editing classes in BlueJ 27

7.1 Compiling the class 28

7.2 Warning message: BlueJ crashed while writing this class 29

8 Keyboard shortcuts 31

8.1 BlueJ 31

8.2 BlueJ Editor 32

8.3 OUWorkspace 34

Appendix – M255 Software Issues and Solutions 36

2
1 Introduction
1.1 The course software
There are four different software components in the course, all of which are installed on your
computer during the installation process (Section 2):
1. Java – to run and develop Java programs you must have Java installed on your
computer. This is done during the first part of the installation process. It is helpful to be
aware of the distinction between the Java Development Kit (JDK) and the Java Runtime
Environment (JRE). If you only want to run Java programs you only need to have the
Java Runtime Environment installed on your computer. However, if you want to develop
Java programs, as you will be doing in M255, you must have the Java Development Kit
(also known as the Software Development Kit, or SDK) installed. Both the JDK and JRE
are installed by the M255 installer. In M255 you very seldom use Java commands
directly, however, in Unit 9 you do run some Java programs directly from the Windows
command prompt.
2. BlueJ – the integrated development environment used in M255. In M255 you do not use
all the features of BlueJ, but it provides a simple environment for developing and
documenting classes. Sections 4 (Launching BlueJ), 5 (Using BlueJ) and 7 (Editing
classes in BlueJ) of this guide describe those features of BlueJ with which you need to
become familiar. BlueJ was not developed at the Open University and you can find out
more about it at www.bluej.org.
3. M255 specific BlueJ projects – the BlueJ projects developed by the M255 Course
Team. You will investigate and extend these projects throughout the course.
4. The OUWorkspace – a general-purpose Java programming tool developed by the M255
Course Team. The OUWorkspace is launched from within BlueJ and can be used to write
Java code to create instances of any classes contained in the currently opened BlueJ
project, and to send messages to those objects. Any object created in the OUWorkspace
can also be inspected to view its current state.

1.2 Using this document


This guide is designed to be used as a reference document. It is not intended to be read from
cover to cover, rather we expect you to you dip in and out of it as necessary throughout the
course.
The following list indicates parts of the course where sections/subsections of this guide may
prove particularly useful:
Unit 1: Section 2 Installing the course software
Section 3 The Amphibian Worlds and Accounts World applications
Unit 3: Section 4 Launching BlueJ
Subsection 5.1 Opening projects
Subsection 5.2 Opening an OUWorkspace
Section 6 Using the OUWorkspace
Unit 4: Section 7 Editing classes in BlueJ
Subsection 5.11 BlueJ Help
Subsection 5.12 Generating project documentation
Unit 5: Subsection 6.4 Resetting the OUWorkspace using the F12 key
Unit 6: Subsection 5.5 Adding a class to a project

3
2 Installing the course software
To install the software from this CD-ROM onto your hard disk, insert the CD-ROM into an
appropriate CD drive. An installation program should start automatically, but if the ‘autorun’
feature has been disabled then you will need to run the M255 set-up program on the
CD-ROM. To run the set-up program click on the Start button, then select Run…, next click
on the Browse button and navigate to the CD-ROM drive containing the CD-ROM. Here
select M255setup.exe (it may just appear as M255setup) and click the Open button. Finally
select the OK button.
The second screen of the installer is shown in Figure 1.

Figure 1 The second screen of the installer


All these options must be installed for you to run the M255 software
successfully. Visually impaired users should check the box ‘Support for Note that for the purposes of
screenreader (visually impaired) users required.’ The version numbers of the this document the terms JDK
first three components (the Java SDK and its documentation, and BlueJ) are (Java Development Kit) and
likely to change over time, so do not worry if the versions you are presented SDK (Software Development
Kit) are synonymous and
with by the installer have higher numbers to those shown above. When you
interchangeable.
select the Next button you will be prompted with the question: ‘Do you want to
install the Java 1.6 SDK?’
If during the installation
You must select the Yes button to launch the Java SDK installer. Note, if you process nothing seems to
already have this version of the Java SDK installed then the installer will detect happen for a very long time,
this and ask whether you would like to reinstall this. There is no need to then check that there isn’t a
reinstall the Java SDK, so you can select the No button. prompt behind the main
installer window. Check the
The Java SDK installer takes a little while to initialise, but once it has you can
icons in the taskbar and if
install the software by selecting all the default options (just select the Next necessary use ALT+TAB to
button). switch between different
At the end of the Java SDK installation process a browser session may open applications.
displaying a ‘Register your JDK’ page. Please note that you do not have to
register, so can simply close this page.
Once the Java SDK has been installed there may be a delay of several seconds before the
prompt: ‘Do you want to install BlueJ 2.1.3? (This software must be installed for you to study
M255.)’. You must click the Yes button to launch the BlueJ installer, and you should follow the
prompts given.

4
The final screen of the BlueJ installer is shown in Figure 2.

Figure 2 Final screen of the BlueJ installer


Uncheck the option to ‘View the README file’ then select the Finish button. If you forget to uncheck the
After selecting the Finish button the message shown in Figure 3 is displayed. ‘View the README file’
option a text editor will be
opened displaying the file.
You should close the text
editor window in the usual
way.

Figure 3 The message shown following the completion of the BlueJ installer
BlueJ is launched at this point so it that it can be configured to use the correct version of Java
(this process will ensure any previously installed older versions of Java do not cause problems).
When the OK button is selected a window similar to that shown in Figure 4 appears.

Figure 4 BlueJ Launcher window showing the Java SDKs present on a computer

5
M255 requires that you use Java 1.5 or above but Windows Vista users must
use Java 1.6 or above for everything to work correctly. We therefore strongly To change the version of
recommend that all users use Java 1.6 (or above), so you should select Java used by BlueJ after
(highlight) the Java 1.6.0_07 option and then select Launch BlueJ. Two things installation, see Subsection
4.1.
then happen and the order in which these happen depends on the speed of
your computer.
1 The BlueJ splash screen (Figure 5) will appear followed by the main BlueJ

window (Figure 6).

2
The installer will display the window shown in Figure 7.
It is important that you do not respond to the installer window (Figure 7) until after you have
closed the main BlueJ window (Figure 6).

In a very, very few cases, the


BlueJ splash screen appears
and is not followed by the
main BlueJ window, before
assuming this is the case
check that the main BlueJ
window has not opened
behind the installer window
using ALT+TAB. If there is no
main BlueJ window you
should proceed with the
installer after reading
Subsection 4.2.

Figure 5 The BlueJ splash screen.


Once the main BlueJ window is open you should close it by selecting the Project menu and
then the Quit option.

Figure 6 The main BlueJ window

6
Figure 7 Message shown once the Java SDK for use with BlueJ has been selected
Once BlueJ has been closed, the OK button shown in the installer window (Figure 7) can be
selected. The prompt ‘Do you want to install the Java 1.6 documentation?’ will be displayed.
You should select ‘Yes’ and select all the default options. In particular, do not change the
destination folder for the Java 1.6 documentation as this is based on the Java 1.6 SDK you
have selected to use with BlueJ. The documentation will take some time to install.
Following the installation of the Java 1.6 documentation the installation continues without any
further prompts. Once the installation has finished you will see three new icons on your
desktop:
• BlueJ,

• M255 Amphibian Worlds,

• M255 Accounts World

and two new groups:


• BlueJ,

• M255

in the Start Menu.


Note for screenreader users. If you checked the ‘Support for screenreader (visually
impaired) users required’ checkbox then you should also install the Java Access Bridge
(version 2.0.1) from the CD-ROM. To do this you will need to navigate to the AccessBridge
folder on the CD-ROM (if this requires reinsertion of the CD-ROM into your drive, to avoid
running through the installation process again, click Cancel at the first screen given followed
by Exit Setup on the confirmation dialogue). Once at the AccessBridge folder double-click on
the accessbridge-2_0_1.exe file and work through the dialogue boxes subsequently
presented.

7
3 The Amphibian Worlds and Accounts World
applications
You can run certain M255 applications directly from Windows. In particular the
Amphibian Worlds (Units 1 and 2) and Accounts World (Unit 2) have been installed so that
you can open them from Windows easily.
The terminology ‘Select Start
3.1 Amphibian Worlds | Programs | M255 |
Amphibian Worlds’ means
To open the Amphibian Worlds application either select the Start button on the
• Double-click on the M255 Amphibian Worlds icon on the taskbar, then the Programs
option (or All Programs in
desktop
Windows XP) followed by the
or M255 program group and
finally the Amphibian Worlds
• Select Start | Programs | M255 | Amphibian Worlds option.

The application window shown in Figure 8 will appear.

Figure 8 The initial window of the Amphibian Worlds application


This application contains a series of microworlds (containing amphibian-like objects), which
will help you to explore object-oriented ideas – various amphibian microworlds can be opened
using the Microworld menu (Figure 9).

Figure 9 The various microworlds available from the Microworld menu

8
Selecting one of the Microworld menu options, opens the microworld in the current window.
The result of selecting the Two Frogs menu option is shown in Figure 10 (notice how all the
buttons are enabled so you can interact with the frogs).

Figure 10 The Two Frogs microworld of the Amphibian Worlds application


As discussed in Subsection 5.3, it is also possible to launch the Amphibian Worlds application
from within BlueJ.

3.2 Accounts World


To open the Accounts World programming tool either
• Double-click on the M255 Accounts World icon on the desktop

or
• Select Start | Programs | M255 | Accounts World

The application window shown in Figure 11 will appear.

Figure 11 The Accounts World window


As discussed in Subsection 5.3, it is also possible to launch the Accounts World programming
tool from within BlueJ.

9
4 Launching BlueJ
To launch BlueJ either double-click on the BlueJ icon on the desktop, or select
Start | Programs | BlueJ | BlueJ. Once BlueJ has opened, the main window is displayed
(Figure 12). The window is largely blank and the buttons disabled, indicating that a project is
not open. Before you can use BlueJ you must open or create a project (see Section 5).

Figure 12 The main BlueJ window

4.1 Changing the version of Java used by BlueJ


If there is more than one version of the Java SDK on your computer, you can change the
version of Java used by BlueJ. However, provided that during the installation procedure
detailed in Section 2 you select Java 1.6.0_07, you should not need to do this (remember
M255 requires the use of Java 1.5 or above, but we strongly recommend that you use Java
1.6 (or above). Windows Vista users must use Java 1.6 or above.
To change the version of Java used by BlueJ select: Start | Programs | BlueJ | Select VM.
If there are two (or more) versions of Java, a window similar to that shown in Figure 13 will
appear listing the versions of Java available on your computer. As M255 recommends that
you use Java 1.6 (or above), select (highlight) the Java 1.6.0_07 option. The Launch BlueJ
button will then become enabled and clicking it will launch BlueJ with Java 1.6.0_07. Once
you have done this, BlueJ will always launch with Java 1.6.0_07.

Figure 13 BlueJ Launcher window showing multiple Java SDKs

10
4.2 Problem launching BlueJ?
There is a rare problem on some machines that means when BlueJ is launched the splash
screen appears (Figure 5), but when it vanishes the main BlueJ window (Figure 12) does not
appear.
To try to solve the problem you should launch the M255 Utility program using:
Start | Programs | M255 | M255 Utility
The window shown in Figure 14 will be displayed.

Figure 14 The M255 Utility program


Take the following steps.
1 Remove the tick from the ‘Use windows colours’ check box
2 Select the Apply button.
3 Close the M255 Utility program using Files | Exit
4 Try to launch BlueJ.
Note: if BlueJ launches successfully it will look slightly different from the figures in the course
units, however, these changes are purely cosmetic and BlueJ will work exactly as described
in the units.
If BlueJ still fails to launch
If BlueJ still fails to launch then you should either contact your tutor, or the OU Computing
Helpdesk (OU-Computing-Helpdesk@open.ac.uk). If you do this by email you should include
the contents of the BlueJ Debug file. To obtain the file’s contents run the M255 Utility
program, as described above, then select the BlueJ Debug File tab, and copy the entire
contents of the text pane (we recommend that you use the Edit | Select All and Edit | Copy
options to do this to ensure that all the text is copied) into your email message. (Please
remember to supply your Personal Identifier and course code when contacting the OU
Computing Helpdesk.)

11
5 Using BlueJ
Project | Open Project…
5.1 Opening projects means select the Project
To open a BlueJ project use Project | Open Project… this displays a standard menu on the main BlueJ
file dialogue box to allowing a project to be selected. The first time you open a window, then select the Open
BlueJ project the file dialogue box is focused on the My Documents folder and Project… option.
you will have to navigate to the folder containing the M255 projects (the default
location is My Documents\M255\M255Projects). BlueJ remembers the folder of
the last project opened so the next time you open a project the file dialogue will
If you have used a project
be focused on that folder.
recently and you want to
The BlueJ’s file dialogues differentiate between standard Windows folders open it again you can use
(which have yellow icons) and folders which contain BlueJ projects (which have Project | Open Recent to list
brown icons of a slightly different shape). the last twelve projects
opened. To open a project
As an example consider Unit3_Project_1. This project is found in the folder you simply select it from the
M255\M255Projects\Block1 and to open the project: submenu.
• Select Project | Open Project… to open the Open Project dialogue
box.

• Identify the current folder. It will be given in the ‘File name:’ box.
• Navigate to the folder M255\M255Projects\Block1.
• Open the project Unit3_Project_1 either by double-clicking on the project or by
selecting (highlighting) it and clicking the Open button. The BlueJ window will be
similar to that shown in Figure 15.

Figure 15 The BlueJ window with the Unit3_Project_1 project open (and the Frog class
selected and the HoverFrog class displaying that it has been changed)

Please note that, if you are using Windows 98SE or Windows ME, when the project opens
a MSDOS command window (with the title Java) may also be opened. You should not
close this window (it will be closed when the project is closed) but you should either
minimise it, or simply make sure it is behind the other windows on your desktop.

12
The unlabelled icon is the project’s README file. You can open the README
file either by double-clicking on the icon, or by tabbing to the main BlueJ pane Using BlueJ’s keyboard
and using the cursor keys to move to the icon. Use the ENTER key to bring shortcuts is covered in
up the pop-up menu and select open. You can use the README file to make Section 8.
notes about the project. When you close the README file any changes you
have made to it are automatically changed and available the next time you
open the file.
The remaining icons correspond to the Java classes defined in the project: Frog, HoverFrog
and Toad. Class icons can have different visual appearances depending on the state of the
class. The icon representing the Toad class is the standard class icon.

Figure 16 The standard class icon


The icon representing the Frog class has two diagonal lines in the lower right hand corner
and a thicker outline. This indicates that the class is the currently selected class in the
window. Using the Enter key at this point brings up a menu which allows you to either compile
or edit the class.

Figure 17 A selected class


The icon representing the HoverFrog class has diagonal lines running across the icon. This
indicates that the class has been changed since it was last compiled. You must compile the
class before using it otherwise you will not see the effect of the latest changes made to it.

Figure 18 A changed class


Arrows may be shown linking the icons of the classes. In Figure 15 there is an arrow with an
open head pointing from the icon of the HoverFrog class to the icon of the Frog class. This
shows that the HoverFrog class is a subclass of the Frog class.

5.2 Opening an OUWorkspace


The OUWorkspace is an integral part of M255, it is opened by selecting
Tools | OUWorkspace from the main BlueJ window. Using the OUWorkspace is dealt with in
detail in Section 6.

5.3 Opening Amphibian Worlds and Accounts World from within BlueJ
If you launch BlueJ and open the Block1 project AmphibianWorlds you will find that the last
option on BlueJ's Tools menu (below OUWorkspace) is ‘Amphibian Worlds’. If you select this
menu option then the Amphibian Worlds application will launch in exactly the same way as if it
had been opened directly from the Windows desktop or the Start menu.
Similarly, if you open the Block1 project AccountsWorld you will find the last option on BlueJ's
Tools menu will be ‘Accounts World’. Selecting this option will launch the Accounts World
application in the same way as if it had been opened via the Windows desktop or Start menu.

13
When you open an application in this way BlueJ may still be the active window on the
desktop. In most cases the application window will be visible on the desktop and you just
need to switch to it. Sometimes the application window opened is hidden behind other
windows, so if you can’t see the application window, check the taskbar or use ALT+TAB to
cycle through the current windows.

5.4 Creating a new project


To create a new project use BlueJ's Project | New Project… menu option. This displays a
standard file dialogue box to allow you specify the project to be created. The file dialogue box
will be focused on the folder containing the last project opened (or My Documents if you have
never opened a project), and if necessary you can navigate to the required folder for the new
project. Enter the project name in the File name: box and select the Create button. A project
name should start with an alphanumeric character and consist only of alphanumeric
characters and the underscore _ character. When the Create button is selected the main
window shows a new empty project containing only the icon of the README file.

5.5 Adding a class to a project


There are two ways to add a class to a project. You can either create a new class in the
project or you can add a copy of an existing class to the project.
Creating a new class
To create a new class in the project either click the New Class… button to the left of the main
BlueJ window or select the Edit | New Class… menu option. You will then see the following
dialogue box:

Figure 19 The Create New Class dialogue


Enter the name of the class in the edit box. By convention class names should start with an
uppercase letter and should consist only of alphanumeric characters. You need to check that
the correct Class Type radio button is checked. In most cases it should be ‘Class’ (which is
the default) to create a standard Java class. Once the class name has been entered and the
correct class type selected, click the Ok button.
When the Ok button is clicked a new class icon will appear in the BlueJ window. For example,
if the class MyClass is created, the following icon will appear:

Figure 20 The icon associated with the newly created class MyClass

14
The icon indicates that the class has been created but has not been compiled. Before the
class can be compiled it needs to be written, and to do this you will use the BlueJ editor (see
Section 7).
Adding an existing class
If you have an existing Java class (that is have access to the appropriate .java file) and wish
to use it in a BlueJ project you can add it to the project using the Edit | Add Class from File…
menu option. This option displays a file dialogue titled ‘Select Java Class to Add’ from which
you may navigate to the project folder containing the .java file of the class. By default this
file dialogue will only list .java files. Either double-click on the required .java file or
highlight it and select the Add button. A new class icon will appear in the BlueJ window
representing the newly added class. The icon indicates that the class has not been compiled.
Before you can use the class you must compile it (see below) even if you do not want to
change it.

5.6 Compiling a class


In most cases a class is compiled from within the editor (see Section 7) but if a class is shown
in the BlueJ window as needing compiling the Compile button to the left of the BlueJ window
or the Tools | Compile menu option will compile all classes in the project which are marked as
needing compiling.
The Tools | Compile Selected menu option will compile only the currently selected class.
However, if that class uses other classes which are marked for compilation then those
classes will also be compiled.
If a syntax error is detected when a class is compiled then the BlueJ Editor will be opened
and the error highlighted (see Section 7).
If the OUWorkspace (Section 6) is open when you compile one or more classes then the
OUWorkspace will be reset, all variables will be removed from the Variables list and the
Display Pane will be cleared, but any code statements in the Code Pane will remain.

5.7 Deleting a class from a project


To delete a class from a project, select that class and use the Edit | Remove menu option.
You will then see the following window:

Figure 21 The class removal confirmation dialogue


Note that selecting the Remove button will permanently delete the class (you will not be able
to recover it) and remove it from the project. You should only select ‘Remove’ if you are
confident that you won’t want to use the class ever again.

5.8 Saving a BlueJ project


There is no need to explicitly save classes, or an entire BlueJ project, because if a class has
been opened for editing (Section 7) any changes made to the class will be automatically
saved when it is compiled or closed.

5.9 Copying a BlueJ project


To create another copy of a BlueJ project use Project | Save As… this displays a standard
file dialogue box. The file dialogue box will be focused on the folder containing the last project
opened (or My Documents if you have never opened a project), and if necessary you can

15
navigate to a different folder to save the copy of the project. Enter the project name you wish
to use for the copy in the File name box and click the Save button. The project name should
start with an alphanumeric character and consist only of alphanumeric characters and the
underscore _ character. The new copy of the project will be opened. The icons representing
the classes will indicate that all the classes need compiling before they can be used.

Remember that all currently


5.10 Resetting BlueJ open windows should be
If BlueJ stops responding, the first thing to check is that there is not an represented by icons in the
OUWorkspace, Amphibian Worlds or Accounts World program open, either Windows taskbar, and that
behind BlueJ or behind another window. If there is, close this window (if you can cycle through all
open windows using
necessary by resetting the program (Subsection 6.4)). If BlueJ is still not
ALT+TAB.
responding check to see if the work indicator shown in Figure 22 is active (that
is appears as a red/white bar, as opposed to the grey/white bar denoting an
idle state), if it is active then you can try resetting BlueJ. To do this either right-click on the
work indicator and select Reset Machine or use the key combination CTLR+SHIFT+R.

Figure 22 The BlueJ work indicator

16
5.11 BlueJ Help
The BlueJ Help menu includes a number of options, most of which you should not need to
use. The important ones for M255 are:
BlueJ Tutorial
This menu option opens the standard BlueJ Tutorial as distributed by the BlueJ developers.
This is a PDF file and to view it you must have Acrobat Reader installed (available on the
P559 Online Applications CD-ROM). Viewing this file is optional.
Java Class Libraries
This menu option will launch your web browser focused on the Java API (Application
Programming Interface) Specification (Figure 23). (The Java API is quite simply all the
classes, and their associated methods, which are available to programmers in the standard
Java development environment.)

Figure 23 Browser window showing the opening page of the Java Class Library
documentation
The most usual use of the ‘Java Class Libraries’ menu option is to find out the details of a
standard Java class. To do this select the class from the frame titled ‘All Classes’ and the
documentation for that class will appear in the main frame.

17
OU Class Library
This option will launch your web browser focused on the classes of the OU Class Library,
which are contained in a package called ou (Figure 24).

Figure 24 Browser window showing the documentation of the ou package


The three classes of the ou package which you will mainly be using are OUColour,
OUDialog and OUFileChooser, these are described in Units 3, 5 and 12 respectively.

5.12 Generating project documentation


The complete documentation for a BlueJ project can be generated using Tools | Project
Documentation and it will be displayed in a browser in a very similar way to the
documentation of the OU Class Library (Figure 24).
For example, if the project Unit3_Project_1 is open in BlueJ (Figure 15) selecting Tools |
Project Documentation will generate the documentation and display it in a browser window
(Figure 25).

Please note that in Section 7 we mention that the documentation for a class can be viewed
in the BlueJ editor. However, for reasons explained in Section 7, it is recommended that
when you want to view the documentation for a class you generate the documentation from
the main BlueJ window and view it in a browser.

18
Figure 25 The documentation of the Unit3_Project_1 class produced using the
Tools | Project Documentation option
If the documentation for the project has previously been generated for the project you will see
the dialogue box shown in Figure 26. It is recommended that you select ‘Regenerate’ as this
will ensure that it accurately reflects the current versions of the classes in the project. If you
select ‘Just Show’ the existing documentation will be displayed, which may not include the
most recent changes to the classes. If your computer is rather slow and you know the most
recent changes to the classes do not affect its protocol then you can select the ‘Just Show’
option.

Figure 26 The documentation regeneration request dialogue box


From Figure 25 you can see that there are links from the documentation of the Frog class to
the documentation of other classes in the project (HoverFrog) and also to classes in the
Java API (java.lang.Object). Unfortunately it is not possible in BlueJ to provide links to
classes in the OU Class Library (e.g. OUAnimatedObject).
The Tools | Project Documentation option generates the documentation using the standard
Java tool Javadoc, and allows you to produce documentation in the same format as the
standard Java Libraries. Javadoc assumes that the Java file containing the definition of the
class is appropriately commented using comments delimited by /** and */. Please be aware
that instance variables and methods that are declared to be private do not appear in the
documentation generated by Javadoc even if they are appropriately commented (because the
user of the class need not be aware of their existence).

19
6 Using the OUWorkspace
An OUWorkspace can always be opened from within BlueJ by selecting
Tools | OUWorkspace.
Only one OUWorkspace may be open at a time. If you try to open an OUWorkspace when
one is already open a dialogue box with the message ‘Only one OUWorkspace open at a
time!’ will be displayed.
When an OUWorkspace is opened it is configured to work with the currently open BlueJ
project allowing you to create and manipulate instances of the classes defined in that project.
In addition you have access to many of the standard Java classes and the classes in the OU
Class Library as described under Help | OU Class Library. If no BlueJ project is open then you
only have access to the standard Java classes and the classes in the OU Class Library.
As the OUWorkspace is configured to work with the currently open project, whenever you
close a BlueJ project (either explicitly when you use Project | Close or implicitly when you
open a different project) any open OUWorkspace will automatically be closed.
Opening an OUWorkspace brings up the window shown in Figure 27.

Figure 27 A newly opened OUWorkspace on the BlueJ project Unit3_Project_1


The title bar of the OUWorkspace includes the name of the BlueJ project which is currently
open, in this case Unit3_Project_1. If no project is open then the title includes the text [No
project open]. The menu options are described in Subsection 6.5. Figure 28 shows an
OUWorkspace that is in use.

20
Figure 28 An OUWorkspace in use
The Code Pane is where you type and execute Java statements. Before statements can be
executed in the Code Pane they must be highlighted (see below). The Display Pane is where
any textual output relating to those executed statements, including error messages, is
displayed. The area labelled Variables holds a list of the currently declared variables in this
case hoppyHeight and hoppy. You can inspect the variables in the Variables list by double­
clicking on them (see Subsection 6.2).

6.1 Executing statements


Type the Java statements you wish to execute in the Code Pane. To execute the statements
highlight them and select the Action | Execute Selected menu option or the Execute Selected
option on the Code Pane’s popup menu.
Errors
If an error is detected when the selected code is executed an error message will be shown in
the Display Pane. An error message is identified as a syntax error, a semantic error or an
exception (as described in Unit 8). If more than one line of code has been evaluated the error
message includes the line number of the code containing the error. This line number is
relative to the highlighted code rather than all the code currently in the Code Pane.
If the executed code contains more than one error only the first error detected will be shown
in the Display Pane as execution of the code stops as soon as the first error is encountered.
Show Results
If the Show Results check box is checked and if the last expression in a statement returns a
value (either an object or a primitive) then that value will be displayed in the Display Pane. If
the Show Results check box is not checked that returned value will only be displayed if it is
included in a System.out.println() statement.

21
6.2 The Inspector window
Figure 28 shows the Variables list containing two variables: hoppyHeight and hoppy. You
can inspect these variables either by double-clicking on the variable in the Variables list or by
highlighting it in the Variables list and using the Enter key. Inspecting a variable opens a new
window. For example inspecting the hoppyHeight variable displays the window shown in
Figure 29.

Figure 29 The inspector opened on the integer variable hoppyHeight

The inspector shows that the variable hoppyHeight holds a value of type int with a value

of 5.

If you inspect the variable hoppy you will see the inspector shown in Figure 30.

Figure 30 The inspector opened on the HoverFrog object referenced by the variable
hoppy
The inspector window shows that hoppy references a HoverFrog object. The inspector
window for an object always has three columns that list: the object’s attributes, the types of
those attributes and the values of those attributes.
When an attribute of type OUColour is shown in an inspector the value displayed is the
actual colour, in this case, yellow. If you try double-clicking on the height and position rows in
the inspector nothing happens, but if you double-click on the colour row another inspector
opens as shown in Figure 31.

Figure 31 An inspector opened on the colour attribute of the variable hoppy


OUColour is a class representing colours in M255 and a colour is defined by its red, green
and blue colour values. As all the attributes of an OUColour object are primitive values of
type int no further inspectors can be opened.
What happens if you inspect a variable which has been declared but not initialised? If we
have executed the statement Frog freddy; in the Code Pane and inspect the variable
freddy the inspector of Figure 32 will be shown. The inspector shows freddy to have a null
value (which is the default value for an object reference).

22
Figure 32 Inspecting an uninitialised variable of type Frog
If we have executed the statement int i; in the Code Pane and we inspect i the inspector
of Figure 33 will be shown. The variable i is shown to have the value of 0 which is the
default value for an int variable.

Figure 33 Inspecting an unitialised variable of type int


To summarise, when you inspect a variable that references an object you see a three column
inspector describing the object’s attributes, and the type and value of those attributes. When
you inspect that holds a primitive value you see a two column inspector giving the type and
value of the variable.
You can have more than one inspector open at a time, however, inspectors do not update
when the value of the variable is changed, so in order to avoid confusion, you are advised to
close any inspector windows before executing any code statements.

6.3 Behaviour of the OUWorkspace when a class is compiled


From Unit 4 onwards you will be making changes to classes using the BlueJ editor, and
before you can test the changes you will need to compile the class (Subsection 5.6). If you
compile a class while the OUWorkspace is open you will find that the OUWorkspace is reset.
All the variables will be removed from the Variables list and the Display Pane will be cleared,
however, any statements in the Code Pane will remain. Any associated Graphics Display
window will also be closed. It is necessary to reset the OUWorkspace when a class is
recompiled, because current instances of that class in the OUWorkspace may not be
consistent with the revised class, and how those instances interact with instances of other
classes in the OUWorkspace may also have changed.

6.4 Resetting the OUWorkspace using the F12 key


You might find that if you execute statements which include a loop (or cause a recursive method
to execute) that nothing appears to happen: no output appears in the Display Pane and you
cannot inspect variables. This may be because the loop includes a large number of iterations
and it will complete if you continue to wait. However, you should consider the possibility that
your code contains an infinite loop. This can easily happen using a while loop (Unit 5) if you
don’t ensure that the loop condition is updated at some point. If you decide to stop the current
execution, rather than wait to see if it will complete, you should use the F12 key.
The F12 key will both stop the current statements executing and reset the OUWorkspace.
Resetting the OUWorkspace will result in the loss of any current Graphical Display and all the
variables created in the current session, but it is the only way to ensure that the OUWorkspace
returns to a stable state. However the statements in the Code Pane are automatically retained.

23
If you hit the F12 key you will see the dialogue box shown in Figure 34.

Figure 34 Dialogue box shown when the F12 key is used

Once the OUWorkspace has reset you will see the following dialogue box.

Figure 35 Dialogue box shown when the OUWorkspace has been reset
If you try to execute statements in the Code Pane while the previous execute statement is still
running you will see the dialogue box shown in Figure 36. You then have to make a decision
as to whether you think the statements just need more time to complete (in which case you
should select No) or if they are never going to complete (in which case you should select Yes
to reset the OUWorkspace).

Figure 36 Dialogue box shown when the OUWorkspace is busy and attempts are made
execute additional statements
Please note that if the OUWorkspace executes an infinite loop it will start to slow your
computer down, by grabbing all the CPU (and depending on the code executing, memory as
well) – if this is the case you should reset the OUWorkspace. All the code you are expected to
execute in the OUWorkspace should execute within a few seconds, so if no response has
been received in that time using the F12 key is probably advisable (unless you have a
particularly slow computer in which case you might need to wait a little longer).

6.5 OUWorkspace menu options


File The Open file dialogue box
• Open – displays an Open file dialogue box focused on the folder of always contains the file
the current project. All text files in the folder are listed. Opening a README.TXT and usually
text file displays its contents in the Code Pane. the file backup.txt. These files
should not be opened using
• Save – saves the statements in the Code Pane to the current file. If the File | Open option.
some of the text in the Code Pane is highlighted then the user is
The current file is either the
prompted to either save all or just the selected text. If the current
last file used in the Open
file is read-only an error message is given. If there is no currently option, or the file to which
selected file a warning message will be given and a file dialogue Code Pane has previously
will be opened as with the Save As option. been saved.

24
• Save As – saves the statements in the Code Pane to a specified file. Selecting
this option opens a file dialogue box focused on the project’s folder. You should
type a valid file name in the File name: edit box. You can omit an extension as if
none is given a .txt extension is automatically added.

• Exit – closes the OUWorkspace. You will be prompted as to whether you wish to
save any statements from the Code Pane to file (unless they have already been
saved).

Edit
• Select All* – selects all the text in the pane.
• Cut – deletes the selected text from the Code Pane and copies it to the system
clipboard.

• Copy* – copies the selected text from the pane to the system clipboard.
• Paste – pastes the contents of the system clipboard into the Code Pane.
• Undo – undoes the previous editing action. Successive uses of undo allows the
user to work back through the most recent edits.

• Redo – redoes the previous editing action. Successive uses of redo allows the
user to work forward again through the most recent undo commands.

• System.out.println(…); – inserts the text System.out.println(); into the


Code Pane. The cursor is positioned between the brackets allowing you to
immediately type in the argument to be displayed.

Items in this menu are only available when either the Code Pane or Display Pane are
selected. If the Code Pane is selected all items are available, but for the Display Pane only
those items marked with a * are available.
Action
• Execute Selected – executes any text which is selected in the Code Pane.
• Clear Display Pane – clears the contents of the Display Pane.
• Clear Code Pane – clears the contents of the Code Pane. If the text in the
Code Pane has been modified and not saved the user will be prompted as to
whether to save the text. If some of the text in the Code Pane is highlighted then
the user is prompted to save all or just the selected text.

• Reset OUWorkspace – clears all the variables in the Variables Pane and closes
any open Graphical Display. The user will be prompted either to retain the Code
Pane in its current state or to clear the text. The option is equivalent to closing the
OUWorkspace and reopening it and if necessary using the Restore Code Pane
option to reload the statements in the Code Pane.

• Restore Code Pane – in the event of either BlueJ or the OUWorkspace crashing,
this option can be used to recover the last statements executed in the
Code Pane.

Graphical Display
This menu is only present if the current open project includes classes which can be displayed
graphically (Amphibians and Shapes).
• Open – opens an instance of the graphical display.
• Close – closes the instance of the graphical display.

25
Code Pane and Display Pane popup menus
• Execute Selected – evaluates the selected text (equivalent to Action | Evaluated
Selected).

• Select All* – selects all the text in the pane.


• Cut – deletes the selected text from the pane and copies it to the system
clipboard.

• Copy* – copies the selected text from the pane to the system clipboard.
• Paste – pastes the contents of the system clipboard into the selected pane.
• Undo – undoes the previous editing action. Successive uses of undo allows the
user to work back through the most recent edits.

• Redo – redoes the previous editing action. Successive uses of redo allows the
user to work forward again through the most recent undo commands.

• System.out.println(…); – inserts the text System.out.println(); into the


Code Pane. The cursor is positioned between the brackets allowing you to
immediately type the arguments to be displayed.

* These are the only two options on the Display Pane popup menu.

26
7 Editing classes in BlueJ
Using the BlueJ editor to edit Java classes is straightforward. To open the editor on a class
either double-click on the class’s icon or select the class and use the Enter key to bring up the
popup menu and select Open Editor. Figure 37 shows the editor opened on the Frog class.

Figure 37 The editor opened on the class Frog


The editor menu actions are listed in Subsection 8.2.
If you change the View drop-down box to from Implementation to Interface the documentation
of the class will be displayed. However, the interface shown in the editor is not always an
accurate reflection of the documentation and the links shown do not necessarily work as
expected. We recommend that if you want to see the documentation of a class you do not use
the interface view of the editor but use the project documentation generated by BlueJ using
the Tools | Project Documentation option on the main BlueJ window (see Subsection 5.12).

27
If you open the editor on the class and it opens with the interface view, or you accidentally
switch to the interface view when using the editor you should switch back to the implementation
view either using the View dropdown box or the Tools | Toggle Interface View menu option.
If you have switched the editor to the interface view and, after clicking on a link, it stops
responding then you need to close the editor window close BlueJ and then relaunch BlueJ.
When you open the editor on the class it will be in the interface view and you should switch it
back to the implementation view using the View dropdown box.

7.1 Compiling the class


When the editor is open on a class it is easy to see if the class has been changed and needs
compiling. If the class has been changed since it was last compiled then the text box at the
right of the information area (at the bottom of the editor’s window) will say ‘changed’ and the
line numbers in the editor will appear on a grey background. Once the class has been
compiled the text box will say ‘saved’ and the line numbers will appear on a white background.
To compile your class either use the Compile button (at the top left of the editor window) or
the Tools | Compile menu option.
When you start the compilation, the message ‘File saved’ will appear in the information area;
if the compilation has completed successfully this message will change to ‘Class compiled ­
no syntax errors’.
If there are syntax errors in the code the ‘File saved’ message in the information area will be
replaced by an error message, and the line of code containing the error will be highlighted.
For example, Figure 38 shows an error when compiling the HoverFrog class.

Figure 38 Part of the editor opened on the HoverFrog class and showing a syntax error in
the getHeight() method
The error message in the information area is very minimal and it may not be sufficient for you
to correct the error. You may be able to get more information on the error by clicking the
? button to the right of the error message. For the error shown in Figure 38. you would get the
additional information shown in Figure 39.

Figure 39 Full error message relating to the error displayed in Figure 38

28
An easy error to make is to miss the semicolon off the end of a statement. If you do this then
typically the line of code highlighted is the one after the statement with the missing ‘;’ as
shown in Figure 40.

Figure 40 Part of the editor opened on the HoverFrog class and showing a syntax error
resulting from a missing semicolon
Clicking the ? button to the right of the error message will display the following dialogue box.

Figure 41 The full error message shown when a missing semicolon is detected
If the OUWorkspace is open when you compile a class then the OUWorkspace will be reset
and all variables will be removed from the Variables list and the Display Pane will be cleared,
but any code statements in the Code Pane will be retained.

7.2 Warning message: BlueJ crashed while writing this class


The rather frightening message shown in Figure 42 can occur when you open the editor on a
class, but usually it is nothing to worry about.

Figure 42 BlueJ warning message

29
This message appears under two circumstances:
1. BlueJ crashed the last time you closed the project.
2. BlueJ did not crash the last time you closed the project, but you did close it
without compiling the class.
In both cases you need to click the OK button to open the editor and then check the class
carefully. If you find that the class has become corrupted then you should follow the
instructions given in the message.
If you find that the message still occurs (it is only shown the first time the editor is opened on
a class during a BlueJ session) once you can compile and use the class, then you can delete
the backup versions of the class. To do this you should use Windows Explorer to navigate to
the project folder and delete the files with the name of the class and the extensions .java#
and .java#backup. So, for example, if you are having problems with the Frog class you
would need to delete the files Frog.java# and Frog.java#backup – you should leave all
other files exactly as they are.

30
8 Keyboard shortcuts
8.1 BlueJ

Project Menu ALT+P


New Project… ALT+P, N
Open Project… CTRL+O
Open Recent � Shows a submenu of the most recently
opened projects
Open Non BlueJ… ALT+P, B
Close CTRL+W
Save CTRL+S
Save As… ALT+P, A
Import… ALT+P, I
Create Jar File… ALT+P, C
Page Setup… CTRL+SHIFT + P
Print… CTRL+P
Quit ALT+P, Q CTRL+Q

Edit Menu ALT+E


New Class… CTRL+N
New Package… CTRL+R
Add Class from File… ALT+E, A
Remove CTRL+Backspace
New Uses Arrow… ALT+E, U
New Inheritance Arrow… ALT+E, I

Tools Menu ALT+T


Compile CTRL+K
Compile Selected CTRL+SHIFT+K
Rebuild Package ALT+T, R
Use Library Class… CTRL+L
Project Documentation CTRL+J
Preferences… ALT+T, P CTRL+Comma
OUWorkspace

31
View Menu ALT+V
Show Uses CTRL+U
Show Inheritance CTRL+I
Show Debugger CTRL+D
Show Terminal CTRL+T
Show Code Pad CTRL+E

Help Menu ALT+H


About BlueJ ALT+H, A
Check Version…* CTRL+V
Installed Extensions ALT+H, X
Copyright ALT+H, C
BlueJ Website* ALT+H, W
BlueJ Tutorial ALT+H, T
Java Class Libraries ALT+H, C
OU Class Library
* You must be online for these options to work.

8.2 BlueJ Editor


Shortcut keys used in the BlueJ Editor.

Toolbar Button Shortcut


Compile ALT+M
Undo ALT+D
Cut ALT+U
Copy ALT+Y
Paste ALT+P
Find… ALT+F
Find Next ALT+N
Close ALT+L
View ALT+V

32
Class Menu ALT+C
Save CTRL+S
Reload
Page Setup
Print… CTRL+P
Close CTRL+W

Edit Menu ALT+E


Undo CTRL+Z
Redo CTRL+Y
Cut CTRL+X
Copy CTRL+C
Paste CTRL+V
Indent more F6
Indent less F5
Comment F8
Uncomment F7
Insert method CTRL+M

Tools Menu ALT+T


Find… CTRL+F
Find Next CTRL+G
Find Next Backward CTRL+SHIFT+G
Replace… CTRL+R
Go to line… CTRL+L
Compile CTRL+K
Set/Clear Breakpoint CTRL+B
Toggle Interface View CTRL+J

Options Menu ALT+O


Key Bindings…
Preferences…

33
8.3 OUWorkspace
Shortcut keys used throughout the OUWorkspace.

Button Shortcut
OK ALT+O
Cancel ALT+C
Yes ALT+Y
No ALT+N
Note:
• Buttons and menu options can be activated with either ENTER or SPACE. The
CANCEL button on file dialogues (File | Open, File | Save As) does not respond
to ENTER, but the dialogue can be closed using ESCAPE.

• The state of check boxes is changed using SPACE (or the shortcut key given
below).

Action Shortcut
Go to Code Pane ALT+C
Go to Display Pane ALT+D
Go to Variables List ALT+V
Show Results (toggle ALT+S
on/off)
File Open Dialogue CTRL+O
Save Code Pane to CTRL+S
current file
Evaluate Selected CTRL+E
Clear Display Pane CTRL+D
Clear Code Pane CTRL+K
Reset OUWorkspace CTRL+R
Restore to Previous CTRL+T
Session
Stop infinite loop and F12
reset Workspace

File Menu ALT+F


Open ALT+F, O CTRL+O
Save ALT+F, S CTRL+S
Save As ALT+F, A
Exit ALT+F, X

34
Edit Menu ALT+E
Select All* ALT+E, A CTRL+A
Cut ALT+E, T CTRL+X
Copy* ALT+E, C CTRL+C
Paste ALT+E, P CTRL+V
Undo ALT+E, U CTRL+Z
Redo ALT+E, R CTRL+Y
System.out.println(…); ALT+E, S CTRL+P
Note:
Items in this menu are only available when either the Code Pane or Display Pane are
selected. If the Code Pane is selected all items are available, but for the Display Pane only
those items marked with a * are available.

Action Menu ALT+A


Execute Selected ALT+A, E CTRL+E
Clear Display Pane ALT+A, D CTRL+D
Clear Code Pane ALT+A, C CTRL+K
Reset OUWorkspace ALT+A, R CTRL+R
Restore Code Pane ALT+A, T CTRL+T

Graphical Display Menu ALT+G


Open ALT+G, O
Close ALT+G, C
Note:
The Graphical Display menu is only present if the project includes classes which can be
displayed graphically (Amphibians and Shapes).
Code Pane and Display Pane popup menu

Execute Selected Shift+F10, E CTRL+E


Select All* Shift+F10, A CTRL+A
Cut Shift+F10, T CTRL+X
Copy* Shift+F10, C CTRL+C
Paste Shift+F10, P CTRL+V
Undo Shift+F10, U CTRL+Z
Redo Shift+F10, R CTRL+Y
System.out.println(…); Shift+F10, S CTRL+P
* These are the only two options on the Display Pane popup menu.

35
Appendix – M255 Software Issues and Solutions

A1 Obtaining installation information 38

A1.1 Where is BlueJ installed? 38

A1.2 Where is the Java SDK 1.6.0_07 installed? 38

A2 Known BlueJ issues 39

A2.1 Launching BlueJ only (briefly) displays the splash screen 39

A2.2 BlueJ suddenly crashes and vanishes from desktop 40

A2.3 Compilation fails to complete 40

A2.4 Compilation fails 40

A2.5 Warning message: BlueJ crashed while writing this class 40

A2.6 BlueJ stops responding 41

A3 Known issues with OU additions to BlueJ 42

A3.1 Amphibian Worlds and Accounts World desktop shortcuts do not work 42

A3.2 bsh.ParseExceptionPane message received on opening the

OUWorkspace 42

A3.3 BlueJ Tools menu does not include OUWorkspace option 42

A3.4 OUWorkspace will not launch from BlueJ Tools menu 42

A3.5 BlueJ Help menu does not include OU Class Library option 43

A3.6 OUWorkspace or Accounts World stop responding 44

36
This appendix is concerned with configuration problems that some students have
encountered – either in BlueJ or the M255 software – rather than the recognised behaviour of
the software (which is covered in the main part of this document).
For some of the fixes described in this section you will need to know the following.
• The installation folder of BlueJ.
Finding this folder is described in Subsection A1.1. The default installation folder
for BlueJ is C:\BlueJ. If you installed BlueJ elsewhere, for example C:\Program
Files\BlueJ, then wherever you see references to C:\BlueJ you will need to
substitute in your particular folder (e.g. C:\Program Files\BlueJ).
• The installation folder of the Java SDK 1.6.0_07.
Finding this folder is described in Subsection A1.2. The default installation folder
for the Java SDK 1.6.0_07 is C:\Program Files\Java\jdk1.6.0_07. If you installed
the Java SDK 1.6.0_07 elsewhere, for example, C:\Java\jdk1.6.0_07, then
wherever you see references to C:\Program Files\Java\jdk1.6.0_07 you will
need to substitute in your particular folder (e.g. C:\Java\jdk1.6.0_07).
Throughout this document, all references to the BlueJ and Java SDK 1.6.0_07 folders are
shown in bold, as a reminder that if you did not install the software in the default location you
will need to change the instructions accordingly.
If BlueJ is not using Java 1.5, or above, the M255 software will not work correctly. Windows
Vista users must use Java 1.6 or above. Currently the course software CD-ROM supplies
Java 1.6.0_07. Subsection A1.2 tells you how to determine which version of Java BlueJ is
using.

Important note on copying files from the installation CD-ROM


Occasionally you may need to copy a file from the installation CD-ROM. Files on a
CD-ROM are set to be ‘read-only’, and this property is retained when they are copied to
your disk. If files have their read-only property set then they may not be replaced as
required during an M255 software update. To remove the read-only property right-click on
the file and remove the tick from the ‘Read-only’ tick box.

37
A1 Obtaining installation information
A1.1 Where is BlueJ installed?
The default installation folder for BlueJ is C:\BlueJ.
The easiest way to determine the installation folder is to right click on the BlueJ icon on the
desktop and select Properties. If the target is C:\BlueJ\bluej.exe then you installed BlueJ in
the default location of C:\BlueJ. If the target is, for example, C:\Program Files\BlueJ\bluej.exe
then you installed BlueJ in C:\Program Files\BlueJ.
If you did not install BlueJ in C:\BlueJ, but in, for example, C:\Program Files\BlueJ, then
wherever you see references (in bold) in this document to C:\BlueJ you need to substitute in
your particular installation folder (e.g. C:\Program Files\BlueJ).

A1.2 Where is the Java SDK 1.6.0_07 installed?


The default installation folder for the Java SDK 1.6.0_07 is

C:\Program Files\Java\jdk1.6.0_07.

The easiest way to determine the installation folder is to launch BlueJ and select

Help | About BlueJ. A window similar to that shown below in Figure A1 will be displayed.

Figure A1 The Help | About BlueJ window


The required information is shown towards the bottom of the window in the line:
Java Home: c:\program files\java\jdk1.6.0_07\jre
This means the installation folder of the Java SDK 1.6.0_07 is
C:\Program Files\Java\jdk1.6.0_07 (without the jre on the end).
If you did not install the Java SDK 1.6.0_07 in C:\Program Files\Java\jdk1.6.0_07, but in, for
example, C:\Java\jdk1.6.0_07, then wherever you see references (in bold) in this document
to C:\Program Files\Java\jdk1.6.0_07 you will need to substitute in your particular
installation folder (e.g. C:\Java\jdk1.6.0_07).
Incidentally, the location shown in the ‘Debug log file’ line at the bottom of the window will
reflect your own username (the name you use to log on to your computer) and thus will differ
slightly from that shown above.
Note: for the M255 software to work the Java version must be 1.5 (or above). If it is not you
must change the version of Java used.

38
A2 Known BlueJ issues
A2.1 Launching BlueJ only (briefly) displays the splash screen
There is a rare problem on some machines that means that when BlueJ is launched the
splash screen appears, but when it vanishes the main BlueJ window does not appear.
To try to solve the problem you should launch the M255 Utility program using:
Start | Programs | M255 | M255 Utility
The window shown below will be displayed.

Figure A2 The M255 Utility program


Take the following steps.
1 Remove the tick from the Use windows colours check box.
2 Select the Apply button.
3 Close the M255 Utility program using File | Exit.
4 Try to launch BlueJ.
Note: if BlueJ launches successfully it will look slightly different from the figures in the course
units, however, these changes are purely cosmetic and BlueJ will work exactly as described
in the units.
If BlueJ still fails to launch
If BlueJ still fails to launch then you should either contact your tutor, or the OU Computing
Helpdesk (OU-Computing-Helpdesk@open.ac.uk). If you do this by email you should include
the contents of the BlueJ Debug file. To obtain the file’s contents run the M255 Utility
program, as described above, then select the BlueJ Debug File tab, and copy the entire
contents of the text pane (we recommend that you use the Edit | Select All and Edit | Copy
options to do this to ensure that all the text is copied) into your email message. (Please
remember to supply your Personal Identifier and course code when contacting the OU
Computing Helpdesk.)

39
A2.2 BlueJ suddenly crashes and vanishes from desktop
This is a hardware problem associated with BlueJ and there are a number of potential solutions.

The first approach to try is to turn off DirectDraw acceleration by carrying out the following steps.

1 Select Start | Run and type dxdiag in the Open edit box and click OK.
2 The DirectX Diagnostic Tool should open – select the Display tab.
3 Disable DirectDraw Acceleration.
4 Click Exit.
If this does not work, the drivers for the video card may need updating, or a later version of
DirectX may be required (the version of DirectX is given on the System tab of the DirectX
Diagnostic Tool and you may find a later version on the Online Applications CD-ROM).

A2.3 Compilation fails to complete


One known BlueJ problem is that sometimes when attempting to compile a class the
compilation will not complete. If this happens the message in the information area of the
editor will display ‘File saved’, but will neither change to ‘Class compiled – no syntax errors’
nor give an error message. The only solution to this problem is to close the editor and quit
BlueJ then, relaunch BlueJ, reopen the editor on the class and compile the class again. This
time the compilation will give an error message. Fortunately this is a very intermittent problem
(although it seems to affect some computers more than others).

A2.4 Compilation fails


If the name of a project folder (or any of its parent folders) contains non-ASCII characters
(such as accents, cedillas and umlauts) when you try to compile a class in that project the
information area may display the message ‘Compiling ...’ for a prolonged period of time,
without compilation actually completing. Unlike in Subsection A2.3 the classes in the project
cannot be compiled even when BlueJ is closed and relaunched.
The solution to this problem is to make sure that the project path does not contain any
non-ASCII characters. The easiest way to do this may be to move your M255 folder so that it
forms a top level folder with a path of, for example, C:\M255. In particular you should try to
make sure there are no spaces, or unusual characters in the path.
Note: this problem has been observed on computers running non-English versions of Windows.

A2.5 Warning message: BlueJ crashed while writing this class


The rather frightening message shown below can occur when you open the editor on a class,
but is usually nothing to worry about.

Figure A3 BlueJ message window

40
This message appears under two circumstances.
1. BlueJ did crash the last time you closed the project. If this is the case click the OK button
to open the editor, check the class carefully and, if necessary, follow the instructions
given in the message.
2. BlueJ did not crash the last time you closed the project, but you did close the project
without compiling the class. Again you should click the OK button to open the editor since
it is prudent to quickly check that the class is correct. We suggest you then try to compile
the class and if necessary correct any compilation errors.
The message is only shown the first time the editor is opened on a class during a BlueJ
session with that project. In most cases, once you have successfully compiled the project the
message will not reappear when the project is subsequently opened. If the message persists
once the class has been compiled you should use Windows Explorer to navigate to the
project folder and delete the files with the name of the class and the extensions .java# and
.java#backup. Thus, if you are having problems with the Frog class you would need to
delete the file Frog.java# and Frog.java#backup – you should leave all other files
exactly as they are.

A2.6 BlueJ stops responding


BlueJ may stop responding if there is an OUWorkspace (or Accounts World) open which itself
has an open dialogue box. If necessary see Subsection A3.6 for details of how to access, and
close, this dialogue box. Once the dialogue box is closed BlueJ becomes active again.
Also see Subsection 5.10 of the first part of this document to find out if BlueJ itself is active
and needs resetting.

41
A3 Known issues with OU additions to BlueJ
A3.1 Amphibian Worlds and Accounts World desktop shortcuts do not
work
If the Amphibian Worlds and Accounts World desktop shortcuts do not work, you can launch
the applications from within BlueJ, as described in the first part of this document (Subsection
5.3). This problem will occur if the M255 Project folder has been moved since the initial
installation, or if the version of Java selected during the installation has been removed.

A3.2 bsh.ParseExceptionPane message received on opening the


OUWorkspace
This message is occasionally seen when opening an OUWorkspace when a BlueJ project is
not open. Before the OUWorkspace opens two error messages are shown in separate
dialogue boxes:
bsh.ParseExceptionPace error at line1, column 8 Encountered: examples
bsh.ParseExceptionPace error at line 1, column 8 Encountered: uninst
These error messages are annoying, but harmless, and do not affect the working of the
OUWorkspace.

A3.3 BlueJ Tools menu does not include OUWorkspace option


If the BlueJ Tools menu does not include OUWorkspace option, check that the file
ouwextension.jar is found in the BlueJ\lib\extensions folder. If you installed BlueJ in the
default location this will be C:\BlueJ\lib\extensions.
If ouwextension.jar is not in this folder you need to copy it from the installation CD-ROM.
It can be found in the libraryfiles folder.
Note: remember to remove the read-only protection from ouwextension.jar before
copying it.
This problem will occur if you have reinstalled BlueJ in a different location and have not rerun
the M255 installer with (only) the ‘Configure BlueJ and Java for M255’ option selected.

A3.4 OUWorkspace will not launch from BlueJ Tools menu


If the OUWorkspace will not launch from BlueJ Tools menu, check that the files ou.jar and
bsh-2.0b4.jar are found in the following locations:
C:\BlueJ\lib\userlib
AND
C:\Program Files\Java\jdk1.6.0_07\jre\lib\ext
If either of these files are missing from either of the locations copy them to the appropriate
location from the installation CD-ROM. They can be found in the libraryfiles folder.
Check that the two copies of ou.jar have the same dates – if they do not ensure that both
are the latest version.
Remember if you copy any files from the CD-ROM you must remove the read-only protection
from them.
This problem will occur if you have changed the version of Java used by BlueJ and have not
rerun the M255 installer with (only) the ‘Configure BlueJ and Java for M255’ option selected.

42
A3.5 BlueJ Help menu does not include OU Class Library option
There are two ways to resolve this problem: either by creating a desktop shortcut directly to

the OU Class Library documentation (this is the easiest way), or by editing the

bluej.properties file to install the necessary menu item in the BlueJ Help menu.

Creating a desktop shortcut


1 Using My Computer (or Windows Explorer) navigate to the folder:

C:\BlueJ\lib\userlib\oudoc

2
Right-click on the file index.html (it may just be shown as index) and from the
menu presented select Create Shortcut. A shortcut called Shortcut to index.html
(or just Shortcut to index) will appear in the folder.
3 Drag the shortcut onto the desktop.
4 Right-click on the shortcut and from the menu select Rename, and change the
name to OU Class Library.
5 Double-clicking the icon will launch the browser focused on the OU Class Library
documentation.
Editing the bluej.properties file
The bluej.properties file is used to set various user preferences in BlueJ. The location
of the this file depends on which version of Windows you are running.
• On Windows XP and Windows 2000 it is found in:
C:\Documents and Settings\<username>\bluej
(where <username> is the name you use to log on to your computer).
• On Windows 98SE and Windows ME it is found in:

C:\Windows\bluej

Note: the bluej.properties file is found in the same location as BlueJ’s debug log file

(bluej-debuglog.txt) and the location of this file is given as the last line on the

Help | About BlueJ window (see Figure A1 in Subsection A1.2).

Make sure BlueJ is not running and then edit the bluej.properties file (using WordPad)

as described below.

1 At the end of the file append these two lines which will add a menu item to

BlueJ's help menu:

bluej.help.ouInfo.label=OU Class Library


bluej.help.items=ouInfo
2 Next add a final line to the file to tell BlueJ where to find the documentation for
the OU Class Library. The oudoc folder containing the documentation is found in
C:\BlueJ\lib\userlib. The two examples given below are based on BlueJ being
installed either in the default folder, C:\BlueJ, or the common alternative,
C:\Program Files\BlueJ (see Subsection A1.1 to determine where BlueJ is
installed on your computer).
bluej.help.ouInfo.url=file\:///C\:/BlueJ/lib/userlib/oudoc/index.html

OR
bluej.help.ouInfo.url=file\:///C\:/Program%20Files/BlueJ/lib/userlib/oudoc/index.html

Note that any spaces in the pathname are replaced by %20, use \ and / as appropriate, and
watch out for the ///.
Once you have added the necessary lines to the bluej.properties file, save it and exit

WordPad. When you next launch BlueJ you should be able to select the OU Class Library

documentation from BlueJ's Help menu.

43
A3.6 OUWorkspace or Accounts World stop responding
Both the OUWorkspace and Accounts World can display dialogue boxes as detailed in the
following examples.
• The Accounts World displays a dialogue when the Add Account button is used.
• The methods of the OUDialog class are used in the OUWorkspace.
• In most cases both the OUWorkspace and Accounts World display a dialogue prompting
the user to save the contents of the Code Pane before they can be closed.

These dialogue boxes are modal. When a modal dialogue box is open it blocks input to all
other windows of that program, so if you have the Add Account... dialogue open in the
Accounts World the main Accounts World window will not respond to any inputs from the user
until the Add Account... dialogue is closed. Similarly, if you have an OUdialog.alert()
dialogue open in the OUWorkspace the main OUWorkspace window will not respond to any
inputs until the alert box is closed.
A problem occurs if the main window overlies the open dialogue box. Consider the following
scenario.
• The Accounts World is open and the Add Account button has been used to open the
Add Account... dialogue.

• An unrelated window has been placed on top of the Accounts World such that the
Add Account... dialogue (or Accounts World) is no longer visible.

• The Accounts World has been brought to the front of the desktop by clicking the Accounts
World button on the TaskBar.

Now the main Accounts World window is visible, but it will not respond because the
Add Account... dialogue is open and waiting for input. Unfortunately the dialogue box is
hidden behind the main Accounts World window.
To bring the Add Account... dialogue in front of the main Accounts World window use the
keyboard as follows.
• Hold down the ALT key and then use the TAB key. A window appears in the middle of the
desktop showing the icons of all the currently open programs. One of these icons will
have a blue box around it, and a brief description of this program will appear at the bottom
of the window. If both keys are released at this point the program corresponding to the
icon with the blue box will be brought to the front and become the active window.

• If the ALT key is held down, successive presses of the TAB key will move the blue box
from one icon to the next and the descriptions change to correspond to the current icon.

• To bring the Add Account... dialogue to the front use the ALT and TAB keys to cycle
through the icons until you find the Java icon (a cup and saucer) with the description
Add Account... Releasing the ALT and TAB keys at this point will bring the Add Account...
dialogue in front of all other windows to become the active window.

• Once the Add Account... dialogue is visible the dialogue can be closed and this returns
control to the main Accounts World window.

Using ALT and TAB allows you to switch successfully to either an OUWorkspace or an
Accounts World regardless of whether or not they have a dialogue box open. Clicking the
appropriate button on the TaskBar will bring an OUWorkspace or Accounts World to the front
of the desktop, but it will only be active provided it does not have a dialogue box open.

44

You might also like