Lab 0: Hello, world Name: __________________
AP Computer Science
Mr. Kretsch
Objective:
Using BlueJ to edit, compile, and run an application
Getting Started
-
Login to your PC
-
If this is the first time you have run BlueJ on this computer you will have to tell BlueJ where Java is.
-
Run the following program: Start→Programs→Math→BlueJ→Select VM menu.
-
BlueJ will display the BlueJ Launcher menu.
-
Highlight the 1.6.0 Java version.
-
Select the Launch BlueJ button.
Once you have done this the first time, you will not have to search for Java again on this system.
-
BlueJ will display its main menu.
Creating the Project
-
Select New Project from the Projects menu to start working on your project, BlueJ will display the New Project menu
-
Select data files…→AP Java→2011-2012→<your login> from the Look In: field.
-
Type “Hello” in the File Name entry, then select the Create button. BlueJ will create a folder in your home folder called Hello that BlueJ will use for your project. BlueJ will display the BlueJ: Hello menu.
-
Select Import from the Project menu.
-
From the Look In menu-bar drill down to the R:\AP Java\Labs\Lab0Hello folder.
-
Once you have arrived at that folder, select the Import button. BlueJ will copy the Java files to your Hello folder and display a box containing Hello on the “white board” of your BlueJ: Hello project menu.
Compiling the Project
-
Double-click the Hello box to view the Hello Java code. BlueJ will open an editor window with the Hello code.
-
Select the Compile button on the editor to compile the program. BlueJ will call Java to compile the program into byte-code. If BlueJ is successful, it will display Class compiled – no syntax errors in the status box
Running the Program
-
Back in the BlueJ: Hello: menu right click on the Hello box to run the program
-
Select the void main (String[]) entry. BlueJ will display the BlueJ Method Call menu.
-
Select the Ok button. BlueJ will open a BlueJ Terminal Window with the text “Hello, Mr. Anderson”, showing that your program was successful compiled and executed.
Changing the Program
The first two instructions in this section you will use for every project this year.
-
Replace the text (your name) with your name in the comment section at the top of the Hello source code.
-
Replace the text (a version number or date) with the current date.
-
In the editor window, find “Mr. Anderson” and change it to your name.
-
Recompile and rerun the program. What do you see?
Running the Program Again
-
Back in the BlueJ: Hello: menu right click on the Hello box to run the program
-
Select the new Hello()
Wrap-up
-
Print a copy of the Hello source code using the Print entry in Class menu of the editor window.
-
Hand in your print-out to Mr. Kretsch
Comments (0)
You don't have permission to comment on this page.