JavaService - Example Commands

JavaService is known to be used successfully with a number of Java applications, for which some example commands are provided below for service installation.

The commands given here cannot be guaranteed to be correct and may require changes to account for different software versions or environment configurations. They are provided purely as an assistance in using the JavaService utility and imply no association with the software described.

Example Scripts

As part of the standard JavaService distribution, a number of example scripts are provided. These can be used to install and configure the relevant application software, subject to any changes required for your specific environment.

These example files are held in the JavaService/scripts sub-directory, according to wherever you have unpacked the distribution zip file. The available scripts are as follows:

InstallOrion.bat / UninstallOrion.bat
Orion Application Server scripts
InstallTomcat.bat / UninstallTomcat.bat
Tomcat service scripts
InstallJBoss.bat / UninstallJBoss.bat
JBoss 3.x Application Server scripts

If you have developed software or scripts so that JavaService can work with other applications, it would be appreciated if you could submit these for inclusion in future releases of this Open Source software.

Orion Application Server Installation

The Orion Application Server is a J2EE-compliant product that runs under the Java run-time environment. The JavaService utility provides a convenient mechanism to run this program as an NT Service.

As the application server requires that an associated database server is already running, there is a need to add a Windows NT Service dependency to the Orion Java Service. The example below shows how this can be defined, with a dependency on the MySql database service in this case. {JDK_HOME} is the location of your JDK and {ORION_HOME} is the location of your Orion installation. The administrator username and password fields also need to be substituted in this command. Please note that this has been used successfully against the V1.5.2 OrionServer release, but is in any case provided 'as is'.

  1. Copy the JavaService.exe file into the {ORION_HOME} directory as OrionServer.exe.
  2. Start a command prompt and change to the directory {ORION_HOME}.
  3. Run the following command:
    OrionServer.exe -install Orion
    {JDK_HOME}\jre\bin\{hotspot|server|classic}\jvm.dll
    -Djava.class.path={ORION_HOME}\orion.jar;{JDK_HOME}\lib\tools.jar -Xms64M -Xmx256M
    -start com.evermind.server.ApplicationServer
    -stop com.evermind.client.orion.OrionConsoleAdmin
    -params "ormi://localhost admin_username admin_password -shutdown"
    -out {ORION_HOME}\log\stdout.log
    -err {ORION_HOME}\log\stderr.log
    -current {ORION_HOME}
    -depends mysql
    -manual
    -append
    -description "Orion Application Server"
  4. To remove the registered service, run the following command from the same directory:
    OrionServer.exe -uninstall Orion

The Orion service can then be started by issuing the following command, which will also start the MySql service beforehand if it is not already running:
net start orion

The Orion service can then be stopped by issuing the following command:
net stop orion

The MySql database service may be stopped as normal by issuing the following command:
net start mysql
This will first stop the Orion service, if it is currently running, following user confirmation.

Tomcat Server Installation

Tomcat is a JSP engine and was the primary reason that JavaService was created. It is a pure Java application that is ideally used as a service, but comes with no native ability to do so.

The following example shows how JavaService can be used to run Tomcat 3.1 as an NT service. The ideas shown here apply to using JavaService with any Java application that needs to run as an NT service. {JDK_HOME} is the location of your JDK and {TOMCAT_HOME} is the location of your Tomcat installation.

  1. Copy the JavaService.exe file into the {TOMCAT_HOME}\bin directory as tomcat.exe.
  2. Start a command prompt and change to the directory {TOMCAT_HOME}\bin.
  3. Run the following command:
    tomcat.exe -install Tomcat
    {JDK_HOME}\jre\bin\{hotspot|server|classic}\jvm.dll
    -Djava.class.path={TOMCAT_HOME}\bin\bootstrap.jar;{TOMCAT_HOME}\bin\servlet.jar;{JDK_HOME}\lib\tools.jar
    -Dcatalina.home={TOMCAT_HOME}
    -start org.apache.catalina.startup.Bootstrap
    -params start
    -stop org.apache.catalina.startup.Bootstrap
    -params stop
    -out {TOMCAT_HOME}\logs\stdout.log
    -err {TOMCAT_HOME}\logs\stderr.log

JBoss Server Installation

The JBoss server software provides a Java run-time environment that can be used for JSP and J2EE applications. In this use, it often needs to be run as a Windows NT System Service, for which the JavaService utility is designed.

Depending on configuration, JBoss may require that an associated database server is already running, which should be set up as a Windows NT Service dependency, with the example below set up against the MySql database. {JDK_HOME} is the location of your JDK and {JBOSS_BIN} is the location of your JBoss binaries installation. These instructions are based on information in the JBoss 3.0 quick-start guide, but are in any case provided 'as is'.

  1. Copy the JavaService.exe file into the {JBOSS_BIN} directory as JBossService.exe.
  2. Start a command prompt and change to the directory {JBOSS_BIN}.
  3. Run the following command:
    JBossService.exe -install JBoss
    {JDK_HOME}\jre\bin\{hotspot|server|classic}\jvm.dll
    -Djava.class.path={JDK_HOME}\lib\tools.jar;{JBOSS_BIN}\run.jar
    -start org.jboss.Main
    -stop org.jboss.Main -method systemExit
    -out {JBOSS_BIN}\stdout.log
    -err {JBOSS_BIN}\stderr.log
    -current {JBOSS_BIN}
    -depends mysql
    -manual
    -overwrite
  4. To remove the registered service, run the following command from the same directory:
    JBossService.exe -uninstall JBoss

The JBoss service can then be started by issuing the following command, which will also start the MySql service beforehand if it is not already running:
net start jboss

The service can then be stopped by issuing the following command:
net stop jboss