University of Toronto at Scarborough - Summer 2001
Department of Computer Science

Printing Program Output

There are several methods that you can use to create output that you will need to submit for your assignments in this course. For take-home Quiz 2 and Assignment 0, we are asking that you perform this simple method of screen capture. For later assignments in the course, you will learn how to specify the input and output files that your Java program uses.


CodeWarrior on Windows NT (on campus)

Please note that the following instructions will not work if you are using Windows 95/98. If all of your output does not fit on the output window at one time, you'll need to do these steps to create a scroll bar on the right side of the output window (this isn't needed for take-home quiz 2):

All future output windows will now have a right-edge scroll bar. To capture all of your output in the paste buffer do the following:

Now open a file with your favorite editor (such as NotePad, found at Start->Programs->Accessories->NotePad), copy the paste buffer into the file (using Control-V or Edit->Paste) and send the file to the printer. If you wish, you can save a copy of your output on the hard drive too.


JDK (on Windows 95/98 at home)

If you have JDK at home, you can create input files that you can redirect to your program (using <). The output of your program can be redirected to an output file (using >).

Follow the instructions that are provided with JDK. In general, you will need to open an MS-DOS Prompt window, and to go to the directory that contains your compiled .class files. Then you'll need to type the following:

   java MyProgram < input.txt > output.txt
   java QuizTwo > output.txt

Or you may find these instructions from Prof. Pancer helpful:

To download a copy of JDK at home, click on the "Java Development Kit" link from this Java 2 web page.


CodeWarrior (on Mac OS at home)

If you have a Macintosh at home, you can use the following directions that were provided by Patrick Pritchard.

First, for input. In CodeWarrior, select Edit -> Java Application Settings
From the Linker menu, select "Java MacOS Settings".

There should be a pull down menu for "Additional Settings" halfway through the preferences window. Click it, and select "Redirect stdin/stdout"

Under the "Redirect stdin" pull down menu, you can choose two options (there are actually three, but we only care about two):

If you select Message Window, it will allow you to type input into the message window.

If you already have an input file called "input.txt", then and store it in the folder with your CodeWarrior mcp file. From the "Redirect stdin" menu, choose "To File", and then click the "Choose" button, and find your "input.txt" file, and select it.

That's it! From now on, whenever you run your program it will read each line from the "input.txt" file as if you had typed it in yourself. Remember to change the settings back to normal when you start your next project though.

Second, saving output. This is pretty easy on the Mac. Simply run your Java application as usual. When the program has finished running, hit COMMAND-A. (Alternatively you can choose Edit -> Select All). That will select all text in the message window (Your Java Console). Now, hit COMMAND-C (or Edit -> Copy). Next, open up a text editor such as SimpleText, TeachText or BBEdit. You can even go back into CodeWarrior and select File -> New Text File.

Once you have started a new file, press COMMAND-V (or Edit -> Paste). That's it! You have now made a copy of your output, and you can print it or save it just like a regular file.

If anyone has any problems, feel free to eMail me (Patrick Pritchard). For reference, my system is an 8500 PPC running OS 9.0.4, and I'm using CodeWarrior Version 5.0 for Java (the latest version available at the UofT bookstore).

Oh, one final note. Click here to see the exact preferences window you should be editing in CodeWarrior.