Making a Program in BlueJ
- Start BlueJ, which will give you this main project window:
- Select the Project Menu / New Project, which will open up the additional
following window. Use the top-middle pull-down list to select a directory,
then enter a name for your project in the “File Name:” window.
- You should now have the following back in your main project window:
- Next select the “New Class” button at upper left. It is a good idea to
make this name the same as your project name. Your window will now look like:
- Double-click on the “Temp1” rectangle inside the workspace. This will open
up a new window which will allow you to type in code.
- Replace the existing section of code called “sampleMethod” with one called
main, so that it looks like:
You could add many lines of code inside this main() method of you wish, such
as multiple output statements.
- Click on the “Compile” button at upper left. If there are errors, fix them.
If not, close the code window (or move it out of the way) so you are back
to the main project window. Right-click on the “Temp1” Object, and select
the “void main()” entry to run your program.
- The results will show up on a terminal window, which will open up separately.
- Hints:
- Subsequent output will be appended to what is already there. To clear
it, select “Clear” from the terminal window Options menu.
- If your program gets stuck, try clicking on the “Barber-pole” horizontal
bar in the project window. If you right-click on it, you get the option
to reset your project.
- If you are storing your program on a USB flash disk from within the lab,
you may need to insert it before starting BlueJ,
otherwise you won’t be able to browse to it from within BlueJ.