TechNote: errout.exe

If your Java program contains any syntax errors, these are reported on the console by the compiler.  Quite often there are many errors.  As we know, the first error is the most critical since the ambiguity created by it is often the cause of subsequent errors.  If a lot of errors are reported, it is difficult to view the first error because the list is long and the first entries are quickly lost off the top of the display.

Normally, output written to the console is captured and displayed one screen at a time by redirecting output to the more command, for example:

            PROMPT>type somefile.txt | more

The type command opens the specified file — in this case, somefile.txt — and writes it to the “standard output”, the console.  However, in the line above, output written to the standard output is “caught” using the pipe symbol (“|”).  It is converted to “standard input” and passed to the program following the pipe symbol.  The sole purpose of the more command is to receive data from the standard input and output it to the standard output, one screen at a time.  Output is paused after each screen of output.  Each press of the spacebar produces the next screen of output. This is a convenient way to view the contents of a text file one screen at a time. 

It would be convenient to use same approach when compiling a Java program:

            PROMPT>javac Example.java | more  (Wrong! This won’t work.)

Unfortunately, this won’t work. The reason is that errors found by the compiler are not written to the standard output.  They are written to the “standard error”, which also defaults to the console in most circumstances.  So, with the above example, errors are still written to the console and, if the list is long, they are quickly lost off the top of the screen.

The solution is to use errout.exe.  This is a utility program provided in ExamplePrograms.zip.  You have already downloaded this file from the ITEC 1011 web page.  Most likely, you extracted all the files into your working directory.  So, you already have the file errout.exe.  You can verify this using the Windows Explorer or using the dir command from a DOS window.  For example, try issuing the following command:

            PROMPT>dir err*

Normally, you will not need the errout utility.  However, if you are debugging a Java program, and there are a lot of errors reported by the compiler, you will experience the problem described at the opening of this tech note. In this case, issue the following command:

     PROMPT>errout javac SomeProgram.java | more

The errout utility converts “standard error” into “standard output”.   Thus, the error list is written to the “standard output”.  With the command above, the list is piped to the more command, and you can view it one screen at a time.  This allows you to see that ever-so-important first error.

Good luck!

S.M. (updated: 15-Mar-01)