File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How to log java.exe errors in bat file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to log java.exe errors in bat file" Watch "How to log java.exe errors in bat file" New topic
Author

How to log java.exe errors in bat file

Michael Moe
Greenhorn

Joined: Aug 30, 2003
Posts: 5
Hi! I have a DOS Batch file that is executed by a Mainframe process. I need to be able to trap any errors generated by running the java program (like class not found), but have not been able to do it as yet. I found that I can check the ErrorLevel and find that an error happened, but I would like to know the specific error. I tried redirecting the output of the java command, but that did not work:
java class > error.log
The file was generated, but no data.
Any ideas?
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Normal messages are printed to System.out.
Error messages are printed to System.err.
The errorstream has a description-number '2';
to log the errors:
java Buggy 2> error.log


http://home.arcor.de/hirnstrom/bewerbung
Michael Moe
Greenhorn

Joined: Aug 30, 2003
Posts: 5
That did it! Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to log java.exe errors in bat file