Hello, there is a jar application, because of some errors that are not related to its operation, it works for some time, and then it receives incorrect requests and does not work correctly. If you restart the application, it starts working as it should and immediately. Until I solve the problem, I need some crutch:
The shell that starts the jar application, then, after some time specified by me, the shell "kills" this application, and then restarts it through java -jar file.jar .
How can this be implemented? Are there bat commands to kill the process or something else? I do not know how to approach the issue.

  • one
    and what operating system? - Mikhail Vaysman
  • Windows 10 Pro x64 - Peter Samokhin

1 answer 1

Temporarily solved my question using a bat-file and a timer in the program code.

  1. In the program code, we set the timer to turn off, for the time that is necessary.
    This is done using Thread.sleep() or the Timer class.
  2. Create a bat file with the following contents:

    : fullrestartlabel
    java -jar file.jar
    goto fullrestartbot
    pause

The essence of the work is as follows : the bat file will simply restart the program forever when it closes. In the program code, we have a timer, it turns out that after the timer expires, the program will restart. (This is a crutch that implements another crutch, but it works the way I wanted, so at the moment it suits me :))