0% found this document useful (0 votes)
59 views6 pages

The Bluej Tutorial: For Bluej Version 2.0.X

Uploaded by

Aymane MOUNTA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views6 pages

The Bluej Tutorial: For Bluej Version 2.0.X

Uploaded by

Aymane MOUNTA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

The BlueJ Tutorial

Version 2.0.1
for BlueJ Version 2.0.x

Michael Kölling
Mærsk Institute
University of Southern Denmark
Table of contents

Copyright © M. Kölling

Contents

1 Foreword 4

1.1 About BlueJ.....................................................................................................................................4


1.2 Scope and audience ........................................................................................................................4
1.3 Copyright, licensing and redistribution ........................................................................................4
1.4 Feedback .........................................................................................................................................5

2 Installation 6

2.1 Installation on Windows.................................................................................................................6


2.2 Installation on Macintosh ..............................................................................................................7
2.3 Installation on Linux/Unix and other systems ..............................................................................7
2.4 Installation problems......................................................................................................................7

3 Getting started – edit / compile / execute 8

3.1 Starting BlueJ .................................................................................................................................8


3.2 Opening a project ...........................................................................................................................9
3.3 Creating objects..............................................................................................................................9
3.4 Execution...................................................................................................................................... 11
3.5 Editing a class.............................................................................................................................. 13
3.6 Compilation.................................................................................................................................. 13
3.7 Help with compiler errors........................................................................................................... 14

4 Doing a bit more... 16

4.1 Inspection ..................................................................................................................................... 16


4.2 Passing objects as parameters.................................................................................................... 18

5 Creating a new project 20

5.1 Creating the project directory .................................................................................................... 20


5.2 Creating classes........................................................................................................................... 20
5.3 Creating dependencies ................................................................................................................ 21
5.4 Removing elements ...................................................................................................................... 21

Copyright © M. Kölling 2
Table of contents

6 Using the code pad 22

6.1 Showing the code pad.................................................................................................................. 22


6.2 Simple expression evaluation...................................................................................................... 23
6.3 Receiving objects ......................................................................................................................... 23
6.4 Inspecting objects ........................................................................................................................ 24
6.5 Executing statements ................................................................................................................... 24
6.6 Multi-line statements and sequences of statements ................................................................... 25
6.7 Working with variables ............................................................................................................... 25
6.8 Command history......................................................................................................................... 26

7 Debugging 27

7.1 Setting breakpoints ...................................................................................................................... 27


7.2 Stepping through the code .......................................................................................................... 29
7.3 Inspecting variables .................................................................................................................... 29
7.4 Halt and terminate....................................................................................................................... 30

8 Creating stand-alone applications 31

9 Creating applets 33

9.1 Running an applet........................................................................................................................ 33


9.2 Creating an applet....................................................................................................................... 34
9.3 Testing the applet ........................................................................................................................ 34

10 Other Operations 35

10.1 Opening non-BlueJ packages in BlueJ ...................................................................................... 35


10.2 Adding existing classes to your project...................................................................................... 35
10.3 Calling main and other static methods ...................................................................................... 35
10.4 Generating documentation.......................................................................................................... 36
10.5 Working with libraries ................................................................................................................ 36
10.6 Creating objects from library classes ........................................................................................ 37

11 Just the summaries 38

Copyright © M. Kölling 3
Other operations

10.6 Creating objects from library classes

Summary: To create objects from library classes, use Tools – Use Library Class.

BlueJ also offers a function to create objects from classes that are not part of your
project, but defined in a library. You can, for example, create objects of class String
or ArrayList. This can be very useful for quick experimentation with these library
objects.
You can create a library object by selecting Tools – Use Library Class… from the menu. A
dialog will pop up that prompts you to enter a fully qualifies class name, such as
java.lang.String. (Note that you must type the fully qualified name, that is the name
including the package names that contain the class.)
The text entry field has an associated popup menu showing recently used classes.
Once a class name has been entered, pressing Enter will display all constructors and
static methods of that class in a list in the dialog. Any of these constructors or static
methods can now be invoked by selecting them from this list.
The invocation proceeds as any other constructor or method call.

Copyright © M. Kölling 37
11 Just the summaries

Getting started
1. To open a project, select Open from the Project menu.
2. To create an object, select a constructor from the class popup menu.
3. To execute a method, select it from the object popup menu.
4. To edit the source of a class, double-click its class icon.
5. To compile a class, click the Compile button in the editor. To compile a project, click the
Compile button in the project window.
6. To get help for a compiler error message, click the question mark next to the error
message.

Doing a bit more...


7. Object inspection allows some simple debugging by checking an object’s internal state.
8. An object can be passed as a parameter to a method call by clicking on the object icon.

Creating a new project


9. To create a project, select New... from the Project menu.
10. To create a class, click the New Class button and specify the class name.
11. To create an arrow, click the arrow button and drag the arrow in the diagram, or just write
the source code in the editor.
12. To remove a class or an arrow, select the remove function from its popup.

Using the code pad


13. To start using the code pad, select Show Code Pad from the View menu.
14. To evaluate Java expressions, just type them into the code pad.
15. To transfer objects from the code pad to the object bench, drag the small object icon.
16. To inspect result objects in the code pad, double-click the small object icon.
17. Statements that are typed into the code pad are executed.
18. Use shift-Enter at the end of a line to enter multi-line statements.
19. Local variables can be used in single, multi-line statements. The names of objects on the
object bench serve as instance fields.
20. Use up-arrow and down-arrow keys to make use of the input history.

Debugging
21. To set a breakpoint, click in the breakpoint area to the left of the text in the editor.
22. To single-step through your code, use the Step and Step Into buttons in the debugger.
23. Inspecting variables is easy – they are automatically displayed in the debugger.
24. Halt and Terminate can be used to halt an execution temporarily or permanently.

Copyright © M. Kölling 38
Just the summaries

Creating stand-alone applications


25. To create a stand-alone application, use Project - Create Jar File...

Creating applets
26. To run an applet, select Run Applet from the applet’s popup menu.
27. To create an applet, click the New Class button and select Applet as the class type.

Other operations
28. Non-BlueJ packages can be opened with the Project: Open Non BlueJ… command.
29. Classes can be copied into a project from outside by using the Add Class from File...
command.
30. Static methods can be called from the class's popup menu.
31. To generate documentation for a project, select Project Documentation from the Tools
menu.
32. The Java standard class API can be viewed by selecting Help - Java Standard Libraries.
33. To create objects from library classes, use Tools – Use Library Class.

Copyright © M. Kölling 39

You might also like