.java
. CodeWarrior requires
Java programs to be organized into projects. For the first few assignments in CS111,
we will create the
project files for you. You will be able to identify the project files by the .mcp
extension (stands for Metroworks CodeWarrior Project)
and the Code Warrior project file icon shown below.
Note the difference from a .java file icon below:
html
file, and thus can be placed on a web page, and
html
file.
.mcp
) file
and double-click it to open it up. Do NOT open (by double-clicking)
the .java
files directly!
Note that the window has 3 tabs: Files, which shows you the files included in the project, Link Order, which allows you to specify the order of compilation of your files, and Targets. In this lab you will only be using Files.
In the right upper corner of the screen, where the active application is shown, you will see MRJApplication.
If MRJApplication is not shown in the right upper corner, but the MRJApplication icon in the project folder is dark, select the MRJApplication from the active programs menu (in the right upper corner):
Now you can quit it, as explained above.
After you quit the MRJApplication, you can run the program again.
If you want to change a file, say Sentence.java
, double-click on it. The text editor called SImple Text will open the file.
Type inm your changes, then choose save from the file menu or press Apple-S.
In the project window you will see a red checkmark next to the file name Sentence.java
: an indication that the file has changed, and the program needs to be recompiled.
However, the Run command and the forward arrow in the project window automatically recompile the project if needed. They also automatically save all the files in the project that have been modified, so usually you will only need to press the forward arrow if you have changed the files.
If all goes well, your program will recompile successfully and run. But what happens if there is a mistake in the code? The program will not compile, and a window pop up displaying error messages:
You can correct the error right in that window or close the error message window and correct it in the original file, the result will be the same. After you have corrected the error, try to run the program again. Note that Java error messages sometimes may not point to the exact spot where the error has occurred. If it's not clear what the error is, carefully check all your code. Understanding error messages is one of the most difficult skills that you will acquire during this course.
Note that not closing an MRJApplication before recompiling the program will also cause an error message, so check (by clicking on the active program list in the right upper corner) if an old MRJApplication is still running. If it is, quit it as described above, and then recompile the program
There may be a different kind of an error in your program when the each piece of the program has compiled correctly, but the program cannot be assembled together. In this case you might see an alert window:
The most likely cause is a misspelled class name. Click on OK and carefully check your code.
Don't forget to save your files on a zip disk or upload them to your private folder (see instructions for Fetch).
Please delete your folder on the machine that you were using: drag it to the trash and empty the trash. It is your responsibility not to leave your work behind for other students to see.