Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a running *.JAR file with a batch script?

We are facing trouble restarting closing a running *.JAR file started with the "java -cp".

Killing java.exe worked fine.

But... isn't there any smoother way for the application? (It saves data on shut-down)

Also, how can one simulate any key input at the following message "Enter any key to continue..." with a batch file?

Thanks for all help!

like image 612
Faizan S. Avatar asked Dec 22 '22 08:12

Faizan S.


1 Answers

The following set of batch scripts can be used to start/stop jars/any program

start-jar.bat

start "win_title" java -jar [jar file] [jar options]

this basically starts your jar(the program) in a window with title set to "win_title".

you could use another batch to kill the window started

stop-jar.bat

TASKKILL /FI "WINDOWTITLE eq win_title
like image 61
Nirmal Patel Avatar answered Jan 03 '23 12:01

Nirmal Patel