*
The moose likes Beginning Java and the fly likes Running java programs from .bat file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Running java programs from .bat file" Watch "Running java programs from .bat file" New topic
Author

Running java programs from .bat file

Mohan Panigrahi
Ranch Hand

Joined: Sep 28, 2001
Posts: 142
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

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Oct 19, 2000
Posts: 113
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running java programs from .bat file