• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running java programs from .bat file

 
Mohan Panigrahi
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have three programs, A.java, B.java and C.java
I want to run them sequentially using .bat file,such that only when A.java does not throw an exception, I should execute B.java else I should execute C.java
Could any one tell me how to write a DOS batch file for this.
Thanks
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
why don't you write a single main class,
which starts your A.java B.java C.java if no
exception is thrown ???
As far as i know there is no exit status in java
like in C for example. So the solution above should be easy and effective.
 
Steve Chernyak
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oliver is right about executing all of the logic from java as a better solution. However, there ARE exit codes in java. If the exit code is not zero, that means the program failed to execute.
The variable errorLevel should contain the exit code in the batch script.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic