Windows or Java Application as Windows Service

Windows applications

see: http://www.serverhowto.de/Applikationen-als-Dienste-einrichten.228.0.html

Java applications (JAR)

We use YAJSW to create a service wrapper for the JAR application.

Precondition:

  • Download YAJSW
  • Java 1.5 or higher (to check call java -version)
    • NOTE: to display system tray java 1.6 is required. For thread dump with locks java 1.6 is required.

How-to use (src):

  • Unpack the zip file to a folder <yajsw> and dont remove or rename
  • Start the application you would like to wrap and get the PID of it (NOTE: not the PID of the batch script)
  • Generate service configuration
    • Goto yajsw/bat
    • execute genConfig.bat <PID>
    • This generates the file yajsw/conf/wrapper.conf which is the configuration file for wrapping your application
    • Stop your application
    • Open conf/wrapper.conf with a text editor
      • set the password for wrapper.app.password or comment out wrapper.app.account (#)
      • Adapt the value of wrapper.ntservice.name
  • Execute your wrapped application as console application by calling
    • runConsole.bat
    • check that your application (for example tomcat) is running
  • To Install the application as service call
    • installService.bat
  • To start the service:
    • startService.bat
  • To stop the service:
    • stopService.bat
  • To uninstall the service:
    • uninstallService.bat
  • You can use the same YAJSW folder for more than one service. Therefore you can use different config files for each application.

For more information see the YAJSW documentation.