Reputation: 2628
I have created batch file and scheduled it for every 1 hour.
Below is the batch file script
set libpath=D:\Batch\Batch_lib
set classpath=%classpath%;%libpath%\aspriseOCR.jar
set classpath=%classpath%;%libpath%\aspriseTIFF.jar
set classpath=%classpath%;%libpath%\cmb81.jar
set classpath=%classpath%;%libpath%\cmbcm81.jar
set classpath=%classpath%;%libpath%\cmbem81.jar
set classpath=%classpath%;%libpath%\cmbicm81.jar
set classpath=%classpath%;%libpath%\cmbicmc81.jar
set classpath=%classpath%;%libpath%\cmbicmcup.jar
set classpath=%classpath%;%libpath%\cmblog4j81.jar
set classpath=%classpath%;%libpath%\cmbsdk81.jar
set classpath=D:\Batch\Batch_1.jar
java -Xms1024m -Xmx1024m -jar Batch_1.jar
exit
This batch file exceutes the runnable jar file. After executing the jar and after some time it throws out of memory exception and the command prompt window is never closed and it also doesn't starts the other command prompt after an hour.
So my concern is how can I close command prompt after it throws any java exception?
atleast it should get closed after an hour.
Upvotes: 1
Views: 837
Reputation: 57282
Java outputs the excpetions to the error stream so you'll need to catch it with redirection to &1 :
java -Xms1024m -Xmx1024m -jar Batch_1.jar 2>&1 | find "Exception" && exit
this should work without wondering about the exit codes.
Upvotes: 2