How can I automatically re-open a program if it terminates / closes / crashes?












1















I've created a Java JAR program that needs to be running all the time in the computer. If the program is closed (either because the user closed it or because it crashed), I need to reopen the program.



I already managed to autostart it whenever I log in the computer, but how can I keep it alive?



I'm not sure whether this should be a programming question or not. After all, auto-starting programs is not a programming question, so I figured that making them persistent could be a similar case.










share|improve this question























  • To be sure here, what is the command used to start-up this java jar program now? what is your method of starting it at log-in? the worlds simplest method would be to use "Start /Wait" methods of running it , and just repeat that in a batch or have an infinite loop. It would help to know first though how your already doing this and with what exact command structure. Are you positive that when it crashes the executable fully terminates?

    – Psycogeek
    Jul 19 '15 at 7:58













  • @Psycogeek it's just a .bat file in the startup folder as described here: stackoverflow.com/a/5953583/555690

    – Omega
    Jul 19 '15 at 9:18
















1















I've created a Java JAR program that needs to be running all the time in the computer. If the program is closed (either because the user closed it or because it crashed), I need to reopen the program.



I already managed to autostart it whenever I log in the computer, but how can I keep it alive?



I'm not sure whether this should be a programming question or not. After all, auto-starting programs is not a programming question, so I figured that making them persistent could be a similar case.










share|improve this question























  • To be sure here, what is the command used to start-up this java jar program now? what is your method of starting it at log-in? the worlds simplest method would be to use "Start /Wait" methods of running it , and just repeat that in a batch or have an infinite loop. It would help to know first though how your already doing this and with what exact command structure. Are you positive that when it crashes the executable fully terminates?

    – Psycogeek
    Jul 19 '15 at 7:58













  • @Psycogeek it's just a .bat file in the startup folder as described here: stackoverflow.com/a/5953583/555690

    – Omega
    Jul 19 '15 at 9:18














1












1








1


1






I've created a Java JAR program that needs to be running all the time in the computer. If the program is closed (either because the user closed it or because it crashed), I need to reopen the program.



I already managed to autostart it whenever I log in the computer, but how can I keep it alive?



I'm not sure whether this should be a programming question or not. After all, auto-starting programs is not a programming question, so I figured that making them persistent could be a similar case.










share|improve this question














I've created a Java JAR program that needs to be running all the time in the computer. If the program is closed (either because the user closed it or because it crashed), I need to reopen the program.



I already managed to autostart it whenever I log in the computer, but how can I keep it alive?



I'm not sure whether this should be a programming question or not. After all, auto-starting programs is not a programming question, so I figured that making them persistent could be a similar case.







windows java






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 19 '15 at 7:50









OmegaOmega

1992517




1992517













  • To be sure here, what is the command used to start-up this java jar program now? what is your method of starting it at log-in? the worlds simplest method would be to use "Start /Wait" methods of running it , and just repeat that in a batch or have an infinite loop. It would help to know first though how your already doing this and with what exact command structure. Are you positive that when it crashes the executable fully terminates?

    – Psycogeek
    Jul 19 '15 at 7:58













  • @Psycogeek it's just a .bat file in the startup folder as described here: stackoverflow.com/a/5953583/555690

    – Omega
    Jul 19 '15 at 9:18



















  • To be sure here, what is the command used to start-up this java jar program now? what is your method of starting it at log-in? the worlds simplest method would be to use "Start /Wait" methods of running it , and just repeat that in a batch or have an infinite loop. It would help to know first though how your already doing this and with what exact command structure. Are you positive that when it crashes the executable fully terminates?

    – Psycogeek
    Jul 19 '15 at 7:58













  • @Psycogeek it's just a .bat file in the startup folder as described here: stackoverflow.com/a/5953583/555690

    – Omega
    Jul 19 '15 at 9:18

















To be sure here, what is the command used to start-up this java jar program now? what is your method of starting it at log-in? the worlds simplest method would be to use "Start /Wait" methods of running it , and just repeat that in a batch or have an infinite loop. It would help to know first though how your already doing this and with what exact command structure. Are you positive that when it crashes the executable fully terminates?

– Psycogeek
Jul 19 '15 at 7:58







To be sure here, what is the command used to start-up this java jar program now? what is your method of starting it at log-in? the worlds simplest method would be to use "Start /Wait" methods of running it , and just repeat that in a batch or have an infinite loop. It would help to know first though how your already doing this and with what exact command structure. Are you positive that when it crashes the executable fully terminates?

– Psycogeek
Jul 19 '15 at 7:58















@Psycogeek it's just a .bat file in the startup folder as described here: stackoverflow.com/a/5953583/555690

– Omega
Jul 19 '15 at 9:18





@Psycogeek it's just a .bat file in the startup folder as described here: stackoverflow.com/a/5953583/555690

– Omega
Jul 19 '15 at 9:18










3 Answers
3






active

oldest

votes


















3














Put this into a .bat/.cmd file. Adjust the java invocation to your needs. Start the cmd file from autostart.
Make sure to use java, not javaw, since you want to wait until it's finished before starting it the next time.



:start
"C:Program Filesjavabinjava" -jar my.jar
goto start





share|improve this answer































    0














    There are several program you can use for this. One is called Control Running Programs (CRP). This is a very good tool to use when having this problem.



    Here's a link for that............



    https://www.raymond.cc/blog/keep-application-running-by-automatically-rerun-when-closed/



    Hope this answers your question, if not let me know.






    share|improve this answer
























    • Please read How do I recommend software for some tips as to how you should go about recommending software. At the very least you should provide more than just a link, for example some additional information about the software itself, for example how it can be used to solve the problem in the question.

      – DavidPostill
      Jul 19 '15 at 10:00



















    0














    There is a question over at stack overflow about how to turn a .bat file into a service:



    https://stackoverflow.com/a/13294293



    The top answer to that question is to use nssm (http://nssm.cc/). When your bat file is made into a service it will automatically restart when it closes.



    Usage for your purpose would be something like the following within an administrator prompt:



    nssm install yourservicename yourbatfile.bat
    nssm start servicename
    nssm stop servicename





    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f942455%2fhow-can-i-automatically-re-open-a-program-if-it-terminates-closes-crashes%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      Put this into a .bat/.cmd file. Adjust the java invocation to your needs. Start the cmd file from autostart.
      Make sure to use java, not javaw, since you want to wait until it's finished before starting it the next time.



      :start
      "C:Program Filesjavabinjava" -jar my.jar
      goto start





      share|improve this answer




























        3














        Put this into a .bat/.cmd file. Adjust the java invocation to your needs. Start the cmd file from autostart.
        Make sure to use java, not javaw, since you want to wait until it's finished before starting it the next time.



        :start
        "C:Program Filesjavabinjava" -jar my.jar
        goto start





        share|improve this answer


























          3












          3








          3







          Put this into a .bat/.cmd file. Adjust the java invocation to your needs. Start the cmd file from autostart.
          Make sure to use java, not javaw, since you want to wait until it's finished before starting it the next time.



          :start
          "C:Program Filesjavabinjava" -jar my.jar
          goto start





          share|improve this answer













          Put this into a .bat/.cmd file. Adjust the java invocation to your needs. Start the cmd file from autostart.
          Make sure to use java, not javaw, since you want to wait until it's finished before starting it the next time.



          :start
          "C:Program Filesjavabinjava" -jar my.jar
          goto start






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 19 '15 at 8:11









          Guntram BlohmGuntram Blohm

          47226




          47226

























              0














              There are several program you can use for this. One is called Control Running Programs (CRP). This is a very good tool to use when having this problem.



              Here's a link for that............



              https://www.raymond.cc/blog/keep-application-running-by-automatically-rerun-when-closed/



              Hope this answers your question, if not let me know.






              share|improve this answer
























              • Please read How do I recommend software for some tips as to how you should go about recommending software. At the very least you should provide more than just a link, for example some additional information about the software itself, for example how it can be used to solve the problem in the question.

                – DavidPostill
                Jul 19 '15 at 10:00
















              0














              There are several program you can use for this. One is called Control Running Programs (CRP). This is a very good tool to use when having this problem.



              Here's a link for that............



              https://www.raymond.cc/blog/keep-application-running-by-automatically-rerun-when-closed/



              Hope this answers your question, if not let me know.






              share|improve this answer
























              • Please read How do I recommend software for some tips as to how you should go about recommending software. At the very least you should provide more than just a link, for example some additional information about the software itself, for example how it can be used to solve the problem in the question.

                – DavidPostill
                Jul 19 '15 at 10:00














              0












              0








              0







              There are several program you can use for this. One is called Control Running Programs (CRP). This is a very good tool to use when having this problem.



              Here's a link for that............



              https://www.raymond.cc/blog/keep-application-running-by-automatically-rerun-when-closed/



              Hope this answers your question, if not let me know.






              share|improve this answer













              There are several program you can use for this. One is called Control Running Programs (CRP). This is a very good tool to use when having this problem.



              Here's a link for that............



              https://www.raymond.cc/blog/keep-application-running-by-automatically-rerun-when-closed/



              Hope this answers your question, if not let me know.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jul 19 '15 at 7:59









              eric24geric24g

              11




              11













              • Please read How do I recommend software for some tips as to how you should go about recommending software. At the very least you should provide more than just a link, for example some additional information about the software itself, for example how it can be used to solve the problem in the question.

                – DavidPostill
                Jul 19 '15 at 10:00



















              • Please read How do I recommend software for some tips as to how you should go about recommending software. At the very least you should provide more than just a link, for example some additional information about the software itself, for example how it can be used to solve the problem in the question.

                – DavidPostill
                Jul 19 '15 at 10:00

















              Please read How do I recommend software for some tips as to how you should go about recommending software. At the very least you should provide more than just a link, for example some additional information about the software itself, for example how it can be used to solve the problem in the question.

              – DavidPostill
              Jul 19 '15 at 10:00





              Please read How do I recommend software for some tips as to how you should go about recommending software. At the very least you should provide more than just a link, for example some additional information about the software itself, for example how it can be used to solve the problem in the question.

              – DavidPostill
              Jul 19 '15 at 10:00











              0














              There is a question over at stack overflow about how to turn a .bat file into a service:



              https://stackoverflow.com/a/13294293



              The top answer to that question is to use nssm (http://nssm.cc/). When your bat file is made into a service it will automatically restart when it closes.



              Usage for your purpose would be something like the following within an administrator prompt:



              nssm install yourservicename yourbatfile.bat
              nssm start servicename
              nssm stop servicename





              share|improve this answer




























                0














                There is a question over at stack overflow about how to turn a .bat file into a service:



                https://stackoverflow.com/a/13294293



                The top answer to that question is to use nssm (http://nssm.cc/). When your bat file is made into a service it will automatically restart when it closes.



                Usage for your purpose would be something like the following within an administrator prompt:



                nssm install yourservicename yourbatfile.bat
                nssm start servicename
                nssm stop servicename





                share|improve this answer


























                  0












                  0








                  0







                  There is a question over at stack overflow about how to turn a .bat file into a service:



                  https://stackoverflow.com/a/13294293



                  The top answer to that question is to use nssm (http://nssm.cc/). When your bat file is made into a service it will automatically restart when it closes.



                  Usage for your purpose would be something like the following within an administrator prompt:



                  nssm install yourservicename yourbatfile.bat
                  nssm start servicename
                  nssm stop servicename





                  share|improve this answer













                  There is a question over at stack overflow about how to turn a .bat file into a service:



                  https://stackoverflow.com/a/13294293



                  The top answer to that question is to use nssm (http://nssm.cc/). When your bat file is made into a service it will automatically restart when it closes.



                  Usage for your purpose would be something like the following within an administrator prompt:



                  nssm install yourservicename yourbatfile.bat
                  nssm start servicename
                  nssm stop servicename






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 4 at 5:09









                  user112770user112770

                  101




                  101






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f942455%2fhow-can-i-automatically-re-open-a-program-if-it-terminates-closes-crashes%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                      Alcedinidae

                      Origin of the phrase “under your belt”?