Search This Blog

Thursday, September 13, 2012

Windows Batch Script to Start, Stop and Restart a JAR file or JAVA Process


Windows Batch Script to Start, Stop and Restart a JAR file



To Start a JAR file using a batch script: 

echo Starting Your_JAR_File_Name!

start "
Your_JAR_File_Name" java -jar PATH_TO_Your_JAR_File_Name.jar


To Stop a running JAR file process using a batch script: 

echo Stopping Your_JAR_File_Name!

TASKKILL /f /FI "Windowtitle eq Your_JAR_File_Name"

Pause


To Restart a JAR file process using a batch script: 

@echo off
echo You are about to restart
Your_JAR_File_Name!

Pause

echo Stopping
Your_JAR_File_Name!

TASKKILL /f /FI "Windowtitle eq
Your_JAR_File_Name"

Pause

echo Starting
Your_JAR_File_Name!

start "
Your_JAR_File_Name" java -jar PATH_TO_Your_JAR_File_Name.jar

No comments:

Post a Comment