practical1doc - BlueJ is an integrated development environment

By Melanie Elliott,2014-04-24 13:33
6 views 0
practical1doc - BlueJ is an integrated development environment

OOPJ Week 1 Practical 1 Introduction to BlueJ

    Source Code for the sample program BlueJ is an Integrated Development Environment (IDE) for Java 2 designed for import java.util.Date; use in a teaching environment by Monash University, Australia (web site public class Test { A. Creating and running a Java program public static void main(String [ ] arg) 1. Start up BlueJ (available from Start in the same menu as TextPad) { 2. Wait for the main window to appear Date d;

    d = new Date(); System.out.println("Eric Pode ran this program on " + d); 3. Check that the window appears similar to the BlueJ Main window opposite }// end method main() 4. Select Project New. Enter the project name OOPJFirstProj }// end class Test BlueJ Main Window 5. Click on the New Class button Enter the class name Test (check capital letters, as shown here)

     Ensure Class type is Class

    6. Select the icon for your new class Test

     Right Click on the icon and select Open Editor 1 Pull down menu 7. Highlight and delete all the code 2 New Class button adds a new class to 8. Enter the program code shown opposite. Ensure that you:-

     a. Put the import statement in the correct place the project b. End statements with semicolons 3 Documentation icon c. Use the correct braces { and } 4 Class icon, striping means it has not d. Use capitals and lower case letters correctly been compiled 9. Click on the Compile button

     Correct any syntax errors (see message at bottom of window) 5 Buttons to add Dependency and

     If there are no syntax errors the click on the Close button Inheritance arrows to the class diagram 10. Note class Test icon no longer has diagonal lines on it. 6 “Working” indicator It has been compiled correctly to a byte-code image. 7 Object Workbench 11. Right click on the Test icon and select the method void main(args) 12. The method call dialogue box will appear, waiting for parameters to be

     entered. As there are no parameters needed, just click the OK button 13. The method will start running (red striped indicator in the left hand panel of Result of running sample program the window will appear briefly).

    14. The results are displayed in the Terminal Window. If this does not appear,

    select View Show Terminal from the BlueJ menu (Shortcut key is Ctl+T)

? Faculty of Computing, Information and English, Page 1 of 2

    Version 1.3, July 2002 51285950.doc

OOPJ Week 1 Practical 1 Introduction to BlueJ

     Example BlueJ Windows

    Terminal Window Options Menu 1 Erases the window contents

    2 Copies text contents to clipboard

    (paste into Word or Notepad) 3 Tick this option to avoid output being

    lost "off the top of the screen"

     1 Right Click to produce this Popup menu 2 Open Editor to view/edit source code 3 Methods (eg main) only available after class has been compiled Debugger Window Features 1 Shows active process

    2 Halts the active process 3 Terminates the active process

    (stops the program running)

    4 Double click to inspect state of

    variables Source Code Editor Window

    1 Compile source code 2 Close editor window Access Debugger Window by 3 Click in margin to set/unset Using View Debugger (Ctrl + D) breakpoints (only available or after code has been compiled) By setting a breakpoint in the source code or Double click on the red Working Indicator

? Faculty of Computing, Information and English, Page 2 of 2

    Version 1.3, July 2002 51285950.doc

Report this document

For any questions or suggestions please email