Using CodeWarrior
Getting Started with Assignment 0
This example is intended to get you started with CodeWarrior. This
example assumes that you are working from CDF-PC on campus. It shows
you how to take Java files that are available to you in the "Handouts"
folder, make your own copy on the H: drive, and then work on your copy
of the files from within the CodeWarrior environment.
We'll assume that you want to get started with Assignment 0. The
following three files have been given to you in the Handouts folder
for Assignment 0: Assignment0.java, Baby.java, and Parent.java.
The Assignment0.java file contains the main method.
There are several ways to do this, but I will describe what I feel
is the simplest method. These steps should be easy enough, even
for those of you who are not that familiar with computers. This
method does not involve using the Explorer program.
- Get your own copy of the files
- For many of the assignments in CSC108, you will be provided with
one or more Java program files, which you simply need to modify as
outlined in the assignment description. These files exist in a
folder called "Handouts." You need to get your own copy of these
files and put them on the H: drive.
- Double click on "Applications" and then double click on
"Handouts." With your left mouse button, click and drag the "Asst0"
folder into the "Home Directory (H:)" icon.
- The remainder of the steps can be done within the CodeWarrior
environment. You'll be working on your own copy of the files for the
assignment, which you have just placed in your home directory (the
H: drive).
- Invoke CodeWarrior
- Double click on the "Applications" folder, and then double click
on the "CodeWarrior" icon.
- Create a new project
- To open a new project, select File->New...
- Click on Java Stationary
- Project name: Asst0
(Choose the name of the directory containing your assignment 0 files.)
- Location: H:\Asst0
(H: is the hard drive where your files are stored, and the
folder Asst0 has to be the same as your project's name.)
Then click on OK.
- Click on the "+" next to Java2 to open it up, and then select Csc
1.0, and click on OK. This will bring up a Asst0.mcp window.
- Tell Java where the main method is
- Select Edit->Java Application Settings...
- Click on Java Target (under the Target settings)
- Main Class: Assignment0
(change TypeYourMainClassHere to be the name of your class
containing the main method).
- Click on Save, and then close the window by clicking the "x"
in the top right corner.
- Include Java Files
- Click on Sources in the Asst0.mcp window to highlight it.
This ensures that the Java files you add will be put into
the Sources folder.
- With Sources highlighted, select Project->Add Files... and
click the Assignment0.java file (which is in the H:\Asst0 folder)
and click on "Add." You can now repeat this step for the Baby.java
and Parent.java classes. (Alternatively, you could have selected
all three files at once by holding the CTRL key and left clicking
each file and then clicking on "Add.")
- The three files will automatically be added to Sources in your
Asst0.mcp window. If you don't see a "+" next to Sources, click
on the various tabs in this window (Files, Link Order, Targets)
to cause it to refresh.
- Click on the "+" next to Sources, and you will see the files that
are part of this program. Double click on one of your ".java"
files to bring up a window that will allow you to view or edit it.
If you make any changes to a file, be sure to save them by
clicking on File->Save.
- Compile
- Select Project->Make. Any compile errors will come up at this
time. They will indicate the line number that has a problem.
- Run
- Select Project->Run. The output will come up in an MS-DOS
window. Any input for the program would be entered here. It
will instruct you to press Enter in this window when the program
has finished.
- Closing CodeWarrior
- Select File->Exit to leave CodeWarrior. Your project will be saved.
- Reopening a Project
- To reopen this Assignment0 project which you have just created,
double click on "Home Directory (H:)," double click on "Asst0,"
and double click on "Asst0.mcp." Asst0.mcp stores all the
information about your project.
- Alternatively, you could have started up CodeWarrior as in step
2, and then you would select File->Open... An Open window will
pop up. You will change the directory in this window until you
get to H:\Asst0, and then you will open the Asst0.mcp file.