Table of Contents
The BlueJ Integrated Development Environment
To install the BlueJ Integrated Development Environment (IDE), go to the BlueJ website: http://www.bluej.org/. Here you will find much information, which you can explore later. Find your OS (Windows, Mac OS X, Ubuntu, etc.) and select the BlueJ Installer with Java 8 JDK. This will install both the IDE and the Java Development Kit which is required for the IDE.
Before Using BlueJ
All your code must be contained in a “Project” in the BlueJ IDE. Later, you will write complex programs consisting of many components, but for now, for most of the programs you write, all your code will be in one file in the project. Before creating a new project, you'll want to set up a folder where you will put all your projects. If you have a folder for CSS 161/162, you may want to create a subfolder called “Projects” that will contain all your Java projects. Create that subfolder first.
Now start BlueJ. To create a new project, under the Project menu, click New Project… . (You'll click on Open Project… to open an existing project.) Get to the folder where you decided you'd store all your Java projects. To get there, use the pull-down menu and then keep clicking on subfolders until you get to your Projects subfolder. Now name your project anything you'd like, but always use meaningful names. Notice that if you look in that Projects subfolder, you'll see a folder named the name of the project you created.
Creating a class (where your code goes)
Now you need to create a class where you will put your code. Under the Edit menu, click on New Class… (or click the New Class button). The class type is Class. The name you give it must follow the rules for all Java identifiers. The rules are that all identifiers must contain:
- only letters,
- the underscore symbol,
- and cannot start with a digit.
For simple programs, you can use the same name as the project (assuming you followed the naming rules). Double-click the class icon to get you into the editor. Delete everything between the first left curly brace and the ending right curly brace. This is where you will type your code.
Before you can execute your code, you must compile it. In the editor window, click the Compile button. If you have compiler errors, the line with the error is highlighted and the error is in the lower window. Note that sometimes the error may actually be on the line above the highlighted line. Compiling shows you one error at a time, so keep compiling until it says
''Class compiled - no syntax errors''
Syntax and compiler errors refer to the same thing; you have not followed the language rules (although from your point of view, they are often just typos).
After you have a successful compile, back at the BlueJ main window, you execute by first right-clicking on the class icon. Click on the method you wish to execute. To run the whole program, click on the
main method, and then the Ok button.
When you run it, the execution appears in the terminal window. Each time you run it, the output is added to what is already there. If you'd like to start with a clear window each time, under the Options menu, click the “Clear screen at method call” item.