File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Running java programs from .bat file" Watch "Running java programs from .bat file" New topic

Running java programs from .bat file

Mohan Panigrahi
Ranch Hand

Joined: Sep 28, 2001
Posts: 142
I have three programs,, and
I want to run them sequentially using .bat file,such that only when does not throw an exception, I should execute else I should execute
Could any one tell me how to write a DOS batch file for this.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
why don't you write a single main class,
which starts your 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:
subject: Running java programs from .bat file
jQuery in Action, 3rd edition