Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to log java.exe errors in bat file

 
Michael Moe
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Michael Moe
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That did it! Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic