简体   繁体   中英

Run jar file from batch file and if some error occurs show meessage

I have a jar file, which is opening two files and in the first one is replacing content and in the second one is removing content. So i want to start this jar file through batch-file but i want when it starts to shows a message that is successfully started and if it is not to print error message that it is not and call "force(-f)" command. I know there must be some check but i do not know how. Could you help me with the script ? Here is my script code for now :

@ECHO OFF
start java -jar jarFile.jar
echo Successfully started!
pause

try that :

@ECHO OFF
IF not exist jarFile.jar GOTO ERROR1
if exist jarFile.jar Start java -jar jarFile.jar
ECHO Successfully started!
PAUSE
EXIT
:ERROR1
ECHO File not found
PAUSE
EXIT

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM