Testing a BlueJ Installation
Assuming you've installed and started BlueJ:
-
Under Project, create a New Project:
![[Image]](pict14.jpg)
Then you will see this:
![[Image]](pict15.jpg)
-
Create a [New Class]. Name it Warning (.java will be added
automatically).
![[Image]](pict16.jpg)
You will see this:
![[Image]](pict17.jpg)
-
Double click on the brown [Warning] box (this is the class).
Erase the sample program (template).
Type in this program (or copy and paste it in).
import javax.swing.*;
public class Warning extends JOptionPane
{
public static void main(String[] args)
{
new Warning();
}
public Warning()
{
showMessageDialog(this,"Warning - Java is addictive");
System.exit(0);
}
}
|
Make sure the name in public class Warning exactly matches
the file name Warning.java (Java is case-sensitive). And be careful
with all the punctuation marks - they are all required.
-
Click on [Compile].
-
If you have errors, the first error message will appear in the output window
at the bottom,
and BlueJ will highlight the offending line (the M is missing from
Message).
![[Image]](pict20.jpg)
-
After a successful compile (Class compiled - no syntax errors),
close the editor.
-
The mysterious part in BlueJ is "running" the program. There is nothing
called "run".
You need to right-click on the brown class box, and choose "void
main(args)"
![[Image]](pict22.jpg)
The following box appears, and you click [OK].
![[Image]](pict23.jpg)
-
If everything worked, you will see the following:
![[Image]](pict24.jpg)
This might pop-up behind other windows - I don't know why. Use
Alt-Tab to find it.
-
In BlueJ, you don't really "run" the program - instead, the testing environment
instantiates the class. This is peculiar at first, but it makes a very
nice test-environment available. Use [View][Debugger] to see the debugging
window.
![[Image]](pict25.jpg)
This will be useful later.
BlueJ might seem a bit peculiar at first, but it is definitely worth the
trouble of learning how it works. The debugging and project management
tools are excellent for IB Internal Assessment projects.