Writing CodeWarrior Java Applications

Bowdoin College Department of Computer Science
revised September 1, 1999




CodeWarrior is a software environment that supports Pascal, C, C++, Java, and Assembly language programming. This document describes how to use the current version of CodeWarrior, called CodeWarrior Professional, to write and run Java application programs. For using CodeWarrior to develop programs in other languages, readers should consult other documentation.


Files and Folders Used by CodeWarrior

CodeWarrior allows large programs to be written as one or more files. When you first start a program in CodeWarrior there are three different kinds of files to keep in mind: These files are all kept in a "project folder," which has the same name as the project file. The project folder is a regular Macintosh folder that holds all the required files for a particular programming project.

Be sure that you have logged into our course folder. To do this select the chooser from the apple menu. Select the zone Hubbard and Appleshare. Once you've done this choose the server "Elephant" and login (your password will start as "changeme" be sure to change it immediately). When using things from the course folder be sure to first copy them to the desktop. At the end of your session you can then save things back to your own folder.

When you write a Java program, you will need to first create a project and then create one or more files that contain the text of that program. These files are all kept in the project folder. After you complete the development of your program, there will be additional files inside the project folder.


Part 1 - Find CodeWarrior and Start It Up

CodeWarrior is on the hard drive of the Macs in the Searles Mac lab and other Mac labs. Look in the CodeWarrior folder on the hard drive and double click on the CodeWarrior IDE 4.0 icon.

(Once you have a project defined and saved, you can just double click on that project file to restart CodeWarrior; this step is only necessary the first time you use CodeWarrior).


Part 2 - Creating a New Java Project

Note: This section is significantly different with the new version of Code Warrior.

In the menu bar, select the New. . . option under the File menu. This creates a dialog box like this:

As in the figure, you want to select the Java Application Wizard, and name your project Lab1 (or something equally clever). Now click ok. You should get a new window like this:

The important bit here is to type in the class name. In the example (true of your first program) the class name is "atinlay". The second important thing is to uncheck the "Create a frame on startup" box. Its not critical but it will simplify things for now. Finally, it might be helpful to get rid of the Package Name setting. You'll go through a couple of more similar windows. You'll want to name these "atinlay" as well. Eventually you'll get to the familiar project window. Before proceeding you need to make one change. Select "Lab1 Debug Settings" from the Edit menu and click on "Java MacOS Settings". You should get a dialogue box like this:

Where it says "Redirect stdin" be sure to select "Message Window" as in the example. This is crucial for any program which reads things in from the keyboard.

Now you're ready to roll on the project. As part of the project creation process a file will be created for you with some default code (in this case the file will be atinlay.java). You can open it by double clicking on its name in the project window. Now you're ready to start programming.