I have a Java GUI-based application that writes some diagnostic messages to System.out and System.err. Where are these messages output when running on Windows? (For example, on Mac OS X, they’re printed to the system console log.)
Edit
I should add that the Java application is packaged as a .exe, so (right now) I can’t launch it using java. (I can copy the individual .JAR files to the Windows test machine, I suppose.)
Also, it’s an app I inherited that didn’t use a logging framework before; I’d like to modify it to use one, but I was hoping to quickly get some log output to diagnose a problem right now.
It really depends on how you launch your application. For example, if you were to launch your GUI from a windows command-line prompt (e.g. such as
java -jar myApp.jar), then as you might expect both System.out and System.err would go to the console. If you’re launching via the Windows shell itself (double-clicking on an executable JAR, for example) then these error streams are lost, to the best of my knowledge. Setting up execution of the app as a service (however unlikely it may sound in your situation) would also lose the output streams.Use of the standard in put and output streams is not typically a good idea unless you’re expecting your program to be called in a shell-script type environment where these are common channels for communication. As you’ve discovered yourself, these are typically not well defined in a GUI environment. If you really want to capture textual information while the program is running, consider using a “real” logging framework (such as log4j or the
java.util.loggingpackage) to capture messages to a log.