Livynwa
Livynwa

Reputation: 1

Running a multiple jar files in a batch file

I'm trying to run a batch file that included multiple jar files, Batch file includes 3 Jar files which executes one after another in one window, My batch file is working correctly for one record which fetches data from excel sheet.

Consider a scenario in which i have 5 records and i wanted to run the batch file in the manner like for 1st record->1st jar prog executes then 1st record->2nd jar file and finally 1st record->3rd jar file executes. Then this loop continues for the second record and likewise. Could anyone please help me to modify the below script which runs in loop and i want to save a executed results in a separate text file.

My script is below:

REM Run first and finish ... java -jar first.jar

REM .. then start number two. java -jar second.jar

REM .. then start number three. java -jar third.jar

Kindly help!

Upvotes: 0

Views: 5164

Answers (3)

Manorama
Manorama

Reputation: 69

If you want to run the jars sequentially, you can write a .bat file containing the following;

@echo off
java -jar first.jar
java -jar second.jar
java -jar third.jar

If you want to tun the jars simultaneously, you can write the .bat file as follows;

@echo off
start java -jar first.jar
start java -jar second.jar
start java -jar third.jar

START command will start running the jar in a new window.

Upvotes: 3

user3395842
user3395842

Reputation:

You cloud do something like this that waits until the execution of one jarfile is done.

@echo off
java -jar 1.jar
pause
java -jar 2.jar
pause

Upvotes: 3

dimoniy
dimoniy

Reputation: 5995

You'll need something like

FOR %%A in (1 2 3 4 5) DO (
java -jar first.jar
java -jar second.jar
java -jar third.jar
)

That should execute the three jar consecutively five times. I didn't actually test this, but it should give you the idea. Here is an article on FOR loops syntax in batch files: http://www.robvanderwoude.com/for.php

Upvotes: 0

Related Questions