Lab1
Introduction to BlueJ
BlueJ is an IDE that provides an editor, compiler and debugger for developing and deploying Java applications. It is also a user friendly tool which makes object-oriented programming even easier.
Start BlueJ
Double click on the icon and the BlueJ window will appear.
Exit BlueJ
- Select Project -> Quit from the menu OR
- Click X
Projects in BlueJ
- Create a Project (using menu)
- Project -> New
Provide a name for project on the prompt
- Open an existing project
- Project -> Open
Select project by browsing to right location of project
- Adding Classes
- Provide a name for class on prompt
- Click New Class on left side OR
- Edit -> Add Class from File
- Editing Classes
- Once the class is created you can:
- Double click on the class icon OR
- Right click and choose Open Editor
It gives you a nice constructor for reference. You can delete or make changes accordingly. Cool thing about this editor is that it enables syntax highlighting. When you compile, the project gets automatically saved, otherwise choose Class -> Save and close.
- Saving a project
- Removable device
- Save As on CD-RW, flash drive etc...
- On Blackboard
- Assignments -> Labs -> ViewAssignment
You can upload the project and save. Do not submit until you are ready to submit, only save.
- On the machine
- Bad Idea.
- Email it to yourself.
- Compiling a project
- Uncompiled project has stripes on it. If project doesn’t compile then it means there is a syntax error in the class. Good thing about BlueJ is that it highlights the line which has error and tries to tell what is missing, expected or wrong.
- Running a project
- BlueJ Object Bench
- Right click on class and choose new ClassName(). This creates a red object on lower left of window. It also allows to provide a name for instance.
You can manipulate the data by right clicking and choosing a method. A method requiring arguments will prompt for input in another window.
- Main Method
- Right click on class icon and choose main method. The program will run and print out the output on a console window.
- Applets, AWT, Swing
- GUI