BlueJ: Common Errors and Problems

BlueJ graphic

 

Help yourselves please...
If you encounter BlueJ errors which should be included in this list, please let us know, so we can make this list as helpful as possible for all students. Thanks.

 

Missing disc drive

If you can't find the disc drive with the Common Data, you need to link it first. Use 'Start' 'MIS Applications' 'Utils' 'Common Data'

'Mixed up' screen display

Sometimes BlueJ does not re-display it's window fully, but leaves areas of a previous window. Rarely, it leaves a whole menu displayed. To force a complete screen refresh simply minimise the window and re-expand it.

Saving the Terminal Window

When trying to save the Terminal Window you may get the message "An error occurred when trying to save the file. The file was not saved."

This may be because you are using the name of a file or folder which already exists but can't be overwritten. Use a '.txt' file extension eg 'Person.txt'

Screen display incomplete

If you are using a low resolution screen you may find BlueJ does not display all the elements you expect. Use the usual Windows facilities to shrink the window so that all elements can be displayed on your screen. (This should not apply to any machines at the Uni.)

Stopping a BlueJ program 

If a BlueJ program doesn't stop you'll need to terminate it.

Open the debugger by: using menu View, Show Debugger OR Ctrl-D OR clicking on the spinning barber pole. Click 'Halt' then 'Terminate' to stop the program. Click 'Close' to close the debugger.

Although this stops the program, some remnants of it may remain. For example, when using the GUI widgets in the package MisIO the program's window will remain on screen. This can be cleared only by closing BlueJ. Such remnants don't prevent your classes being edited or your program from being re-run though.

Terminal window does not display so can't see output 

View Terminal window option When you produce results, maybe using System.out.println, you expect to see those results in a separate 'Terminal Window'. This should be created automatically and contain your results.

If you don't get this window ensure that it has not been de-activated; ensure menu item View | Show Terminal is ticked.


BlueJ Errors Messages

BlueJ provides help with many compilation errors. Use the on-screen Help button.

On-screen Help button
A compiler error and the Help button

The list below is to supplement BlueJ. These are arranged in alphabetic order.


*** expected - compilation error

For example:
" ';' expected"

BlueJ is expecting something different - here a ';'. The line where the error was detected is highlighted.

The usual situation where this would occur is missing a ';' at the end of a line of code. However, since a ';' is not required at the end of every program line don't simply add one. Think about it first.

Cannot return a value from a method whose result type is void - compilation error

Getter methods return a result and its signature (heading line) includes the result's type.

Setter methods don't return a result and include void in their signature. They mustn't include a return instruction.

Can't resolve symbol - compilation or runtime error

For example:
"Error: Can't resolve symbol.
Symbol : variable fred."

BlueJ can't recognise a word you've used, here "fred".

  • This may be because BlueJ is expecting a String and you forgot to include the necessary surrounding quotes, "fred".

  • This error may be because an identifier is mis-spelt: you typed 'modle' instead of 'model'.

    Can't resolve symbol #1
    Can't resolve symbol #1
  • A common situation is forgetting to use capital 'S' for the class name System

    Can't resolve symbol #2
    Can't resolve symbol #2
  • This error might also occur if you used a method name but forgot to follow it by its parentheses '( )'.

Error Saving File

This may mean you're trying to save a file to some folder where you're not allowed to save. If you're using a provided project maybe you didn't change the directory in order to save in your area

Incompatible types - compilation or runtime error

For example:
"Error: Incompatible types.
found : boolean.
required: java.lang.String"

BlueJ has found a boolean (true or false) value where it was expecting a String

IllegalAccessError - runtime error

For example:
"IllegalAccessError:
tried to access class xxx from class _SHELLnn (in _SHELLnn)"

BlueJ has tried use a 'standard' class of the same name as the one you are creating. This may be because you actually are using a class name which has already been used for a standard (imported library) class or because your BlueJ setup is looking in an inappropriate place for standard libraries.

Instance name must be a Java identifier - runtime error

When an instance (an object) is created the name you give it must follow the rules for a Java identifier.

The most likely way in which this may happen is by trying to give an instance a name which includes a 'space'. Use capital letters to make second and subsequent words stand out eg firstBike.

Invalid Java identifier
Invalid Java identifier
Invalid Class Name

A class name can't contain spaces or punctuation characters (other than underscore '_'). It is conventional for class names to start with a capital letter.

NoClassDefFoundError - a runtime error

For example:
NoClassDefFoundError:
aLibrary/AWindow$1 (in aLibrary.AWindow)

A .class file required by the program can't be found. Here it is file AWindow$1.class.

In this example the problem probably arises from an error with the 'aLibrary' library CD distributed with Riley's textbook. To correct this, rename file: AWindow_1.class as AWindow$1.class and
AWindow_2.class as AWindow$2.class

Package *** does not exist

The package is not known to BlueJ. You need to configure BlueJ so that BlueJ can find it. If this is a package you've written or is locally provided (such as aLibrary or MisIO) then follow the configuration instructions. (You dont need to do this to access aLibrary or MisIO at the University.)

 

©: Lisa Payne & Hong Guo, 2002-4
Last update: 8 November 2004