4 Replies Latest reply on Feb 25, 2009 4:43 PM by millerdl

    Launching JBoss from a java application rather than using ru

      I am looking for the proper way, if any, to launch JBoss from a java application. We have always launched JBoss from the run.sh as root. I have been searching the forums for a java class or some other sort of client to launch JBoss, but could not locate a direct method to do this. Could someone point me in the right direction since we can not use run.sh to launch JBoss anymore. If possible we could also launch from a C++ application, but java is just a little more convenient right now. If there is a admin guide or user manual that explains this could someone point me to that. Thank you.

        • 1. Re: Launching JBoss from a java application rather than usin
          peterj

          A couple of possibilities:

          a) System.exec("sh path-to-run.sh");

          b) Include bin/run.jar in your classpath and then do: org.jboss.Main.main(command-line-arguments);

          Option (a) has the benefit of running JBoss AS in a separate process.

          Option (b) runs JBoss AS within the same JVM that started it. This would be suitable if, for instance, you use Groovy scripts.

          If you want to write a C/C++ app to run it, read up on JNI. Or even better, get the JVM source and look at how the java executable is implemented.

          • 2. Re: Launching JBoss from a java application rather than usin

            Does it mean that JBoss cannot be remotely started up or shutdown?

            Is JBoss server a single JVM? I mean that no other admin web server to manage the other JVM or web application. If yes, every time to shutdown JBoss server and all web application will also shutdown. Is it sure. Thanks.

            • 3. Re: Launching JBoss from a java application rather than usin
              peterj

              Remotely start - only if you have some kind of an agent on the remote system, or you remote shell into the system. Another possibility - is you are running on Windows and has JBoss AS set to start as a server you can use MMC to connect to the remote system and start the service. I think that Jopr comes with such agent.

              Remotely stop - use JMX to call the shutdown() operation on the jboss.system:type=Server MBean. Several tools (twiddle, jmx console, embedded jopr, jopr) can do this for you.

              Yes, JBoss AS runs in a single JVM. You can run multiple instances if you like.

              • 4. Re: Launching JBoss from a java application rather than usin

                What is the difference between using org.jboss.Main.main() and org.jboss.system.server.Server.start()?