Free and Easy Java

by Dave Mulkey, Germany, 2004

Testing a BlueJ Installation

Assuming you've installed and started BlueJ:

  1. Under Project, create a New Project:
    Then you will see this:
  2. Create a [New Class].  Name it Warning (.java will be added automatically).
    You will see this:
  3. 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 (Java is case-sensitive). And be careful with all the punctuation marks - they are all required.  

  4. Click on [Compile].
  5. 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).
  6. After a successful compile (Class compiled - no syntax errors),
    close the editor.
  7. 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)"
    The following box appears, and you click [OK].
  8. If everything worked, you will see the following:
    This might pop-up behind other windows - I don't know why.  Use Alt-Tab to find it.
  9. 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.
    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.