next up previous
Next: Edit the program Up: Homework 1: Java compilation Previous: Homework 1: Java compilation

Create and run ``Hello, World!''

The CodeWarrior IDE provides a simple way to create a new program using an existing program as a template. The templates are called ``stationery,'' and there is one on the machines in the Olin Lab that is similar to the ``Hello, World!'' program in the book. We will use this program as the starting place for the first few projects.

1.
Find a happy iMac and start by shutting down any applications that are running. If you click in the upper-right corner of the screen, you will get a list of the things that are running. Whittle it down until only the Finder is left.

2.
From the Apple menu (upper-left corner) go to Programming and select CodeWarrior IDE 4.0. The menu bar should change to indicate that CodeWarrior is now running.

3.
From the File menu select New.... A dialog box will appear.

4.
In the text field named Project Name type the name Hello.prj (the suffix prj indicates that this is a project file).

5.
Double-click on the stationery named cs151HelloStationery, which is all the way at the bottom of the stationery list. Two things should happen: a folder named Hello should appear on the desktop, and a project window should appear in the middle of the screen.

6.
In the project window, click on the little triangle next to the word Sources. This will reveal the source code files that make up the project. There should be only one, named cs151.java

7.
Double-click on cs151.java. It will open a source code window that contains the program. Look over the program and compare it with the one in the book. There may be superficial differences.

8.
From the Project menu, select Run. A window will appear telling you that your program is being compiled, and then a console window will appear with the output of the program, which is the single line of text, ``Hello, World.''

9.
If you look at the list of running application (in the upper right corner), you will see that you are now running something called JBoundApp. This is the new program that was created when you ran the compiler.

10.
BEFORE RETURNING TO THE CODEWARRIOR IDE, YOU MUST QUIT FROM THE RUNNING APPLICATION (JBoundApp). Type Command-Q to quit. You should get dumped back into the IDE.

11.
Close the source code window and the project window. Now switch to the Finder and open the folder named Hello. It should contain five files:

JBoundApp
This is your compiled and ready-to-run program. You can double-click on it to run it any time (it doesn't need CodeWarrior any more, I think).

Hello Data
This is a folder, but I don't really know what's in it. You can delete it with impunity.

cs151.java
This is your source code. You can double-click to open it, but it is usually a better idea to open the project file instead.

Hello.prj
This is your project file. The best way to reopen your project is to double-click on the project file; it will start CodeWarrior if it is not already running.

AppClasses.jar
You don't want to know.

12.
Double-click on cs151.java. Your program will appear, but the project window will not. You can modify the program, but you will not be able to run it unless the project window is open.

13.
Double-click on Hello.java. It will open the project window, and you should now be able to run the program.

14.
DON'T FORGET TO QUIT THE APPLICATION AFTER EVERY TIME IT RUNS. You might notice, though, that if there is a compile-time error, and the program doesnt run, you don't have to quit, because you will still be in the IDE.


next up previous
Next: Edit the program Up: Homework 1: Java compilation Previous: Homework 1: Java compilation
Allen B. Downey
1999-09-08