4 Replies Latest reply on Feb 11, 2005 12:20 PM by davidchen

    Can I call run.bat from a java application?

    davidchen Newbie

      Hi, there:

      I have a question about jboss start. Can I call run.bat from a stand alone java application? by using:

      Process proc=Runtime.getRuntime().exec("C:/jboss-2.4.8/bin/run.bat");
      

      I did try, but no any luck, it totally hangs my application (of couse the jboss did not get started at all). If I'm not supposed to start jboss server from java application, then why? or is there any other work around to start jboss dynamically from application? how?

      Thanks a lot in advance
      David

        • 1. Re: Can I call run.bat from a java application?
          Darran Lofthouse Master

          At what point does it totaly hang your application? Does the call to exec return you a process instance or is this the point that it hangs?

          The process instance contains an error stream and an output stream, according to the API documentation you need to be reading these or the application could block. Is there any information being reported on either of the streams?

          The run.bat script needs to be executed with the working directory being the directory that contains the run.bat script, in your invocation to exec you have not set the working directory, where is your applications working directory?

          • 2. Re: Can I call run.bat from a java application?
            Franco Apprentice

            Hi,
            you shoud use: START C:\.....
            The run.bat is never ending

            • 3. Re: Can I call run.bat from a java application?
              davidchen Newbie

              Thank you very much Darranl. You are right. When I put my application class under jboss/bin directory and exec "run.bat", then it works. It's my fault, we can not call run.bat outside bin directory.
              Thanks again. However, just wonder if it a good approach? now I have issues to stop jboss.
              1. in my application, I'm using process.waitFor() and, it will never return until jboss terminated, so, I can not use waitFor(), but using some sleep() to wait for jboss get started.
              2. because I started jboss through my java application, after my application finished, there is no console window for jboss running. Which means I can not stop jboss by sending "CTRL-C", instead, I should write another application to call jboss stop script instead.
              3. runtime.exec() will get jboss started in a separate JVM, am I right? will that bring some issues?
              Is there any other options? Highly appreciated if any suggestions

              Thanks a lot
              David

              • 4. Re: Can I call run.bat from a java application?
                davidchen Newbie

                Thank you fbiaggi, I guess your reply answered my questions in my previous reply. sorry I submitted my previous reply without checking your reply. I'll try to call "start run.bat" instead.

                Thanks a lot again
                David