Friday, October 12, 2007

Java Faqs - How can I store the errors from the javac compiler in a DOS file?

javac foo.java > errorfile doesn't work.

javac writes errors to stderr, The problem is that DOS doesn't allow stderr to be redirected (as command.com is very poor software). So you have to use a special error redirection mechanism in the compiler:

javac -J-D javac.pipe.output=true myfile.java > errors.txt

In JDK 1.2, you can use: javac -Xstdout You typically use this when a compilation produces a lot of errormessages, and they scroll off the DOS window before you can read them.

Alternatively, you can get a scollbar to appear on a DOS window by changing the properties with the "Layout" tab. Change the Screen Buffer Size Height: to some multiple > 1 of the Window Size Height. E.g. use a buffer height of 100 and screen height of 25 (the default). This will give you three buffers of scroll "history."

No comments: