BlueJ Intro


What is BlueJ

BlueJ is an Integrated Development Environment (IDE) in use for writing Java programs. A programmer could write all code in notepad, then compile via the command line. BlueJ provides ways to avoid this. Also, it provides many features to help the programmer write better code, and to avoid common programming errors. BlueJ can be obtained from the following website:

Using BlueJ

When you first open up BlueJ, you will be greeted by the screen below. Whenever you start a new project for this course, you will go to the project menu. Go ahead and create a new project called HelloWorld. Save this project in the default directory.

image of bluej

Once you have done this, press the new class button. This will allow you to create a new java program within the project. Select the Intro to Java template (the other templates are much more complex than what we will get into during this course). Name the class HelloWorld.

image of bluej

This will create a rectangle in the project window with the title HelloWorld. This is the visual representation of your program. The diagonal blue lines mean that the project has not been compiled. We will solve this problem in a minute. For now, double click on the HelloWorld rectangle.

image of bluej

This is the place where you will do actual coding. Your code will actually go where it says //YOUR CODE HERE. Replace that line with System.out.println("Hello World!"); (NOTE THE ';' at the end of the line). When you are done, press the Compile button.

image of bluej

Once you have finished that, close the window (press the 'X' in the upper right hand corner). Then, right click on the HelloWorld rectangle, and select the void main(String[] args) options. Press OK on the next dialog box. You should get a screen that looks like below.

image of bluej

Writing Java Programs

Let's take a look at a very simple java Hello World program:

	public class HelloWorld{
	     public static void main(String[] args){
                  System.out.println("Hello World!");
The first important item to note is the class name. The class name of this file is HelloWorld. Note that the name of the file is This is a requirement of your java programs (they will not compile without this satisfied).

Next, we have the method header for the main method. When you run the program from the command line, the code within the main method is executed. In BlueJ, we can select which methods to run from the drop-down box. We will cover more about method headers later this week.

Then, finally, we have the actual code that gets executed. System.out.println is the method you use in order to print text to the screen. As we work throughout the week, we will learn more methods we can use to accompilsh more.

Exercise 0: Make a new class called NameAge. Add a line that will print your name and age to the screen. Compile and run this program.