When one opens BlueJ, one will see the following screen:
Each program is called a project in Java. To create a new project (i.e., write a program), one clicks on the “Project” pull-down menu and one gets:
Then highlight and click on “New Project”. The following will then appear:
One first chooses where the project should reside. The default will be in the “bluej” directory. (If one is working in the lab, one should put the project on the “a:” drive, the floppy disk.) One types in the project name in the “File Name” text box. Then one clicks on the “Create” button. When one does this (I have chosen the project name as “Program1”, the following will appear:
The text file is for documentation of the project, a sort of ‘readme.txt’ file. The text file will be as follows:
------------------------------------------------------------------------
This is the project README file. Here, you should describe your project.
Tell the reader (someone who does not know anything about this project)
all he/she needs to know. The comments should usually include at least:
------------------------------------------------------------------------
PROJECT TITLE:
PURPOSE OF PROJECT:
VERSION or DATE:
HOW TO START THIS PROJECT:
AUTHORS:
USER INSTRUCTIONS:
One should fill in the required information:
------------------------------------------------------------------------
This is the project README file. Here, you should describe your project.
Tell the reader (someone who does not know anything about this project)
all he/she needs to know. The comments should usually include at least:
------------------------------------------------------------------------
PROJECT TITLE: Program1
PURPOSE OF PROJECT: Prints out a Message
VERSION or DATE:
HOW TO START THIS PROJECT: Right click on the class “Message”
AUTHORS: your name here
USER INSTRUCTIONS:
Next, one wants to create the classes necessary for this project. So one clicks on “New Class”, and one gets the following:
You type in the name of the class (Message) and choose one of the four possible types, in this case the default “Class”. (We will discuss all four types during the quarter.) Then after typing in the name and hitting the “Ok” button, one gets:
To add information to this class, one “double clicks” on the class. When one does this, one gets the following prototype:
What one gets is the ‘default class type’ presented by ‘bluej’. Note that this is only for the IDE of ‘bluej’. Other interfaces will give different defaults. You should fill in the information, about what it does, your name and the date you created it. The rest of the class is a protoype of what a class would look like. It gives a member of the class (the declaration of int x), a constructor for the class (the function ‘public Average’), and an example of a method, called ‘SampleMethod’. (Classes consists of a members and methods. The constructor is a method.) Usually, the simplest thing to do in writing a program is to just erase all of this. One highlights all of the code inside the class definition:
and one then hits the ‘delete’ key or the ‘enter’ key, and one is left with an empty class:
At this stage, one types in the program that one wants:
Next one must compile the program to make sure there are no errors. To do this, just click on the ‘compile’ button. If there are on errors one will get the following (if one has no syntax errors):
Note that before the ‘Class compiled- no syntax errors’, a message of ‘file saved’ will appear. This means the the new version of this file has been saved in the project directory.
To run the program one must get back to the project screen:
One clicks on the button “BlueJ:…” above to get back to the project screen. To run the program you right click on the “Message” icon and the following will appear:
Then put the cursor over the ‘void main(arg’) tab:
and click on it, which will yield the following screen:
Just click on the ‘Ok’ button and one will have the “Terminal Window” window appear:
.