Java Apps as Windows Service


I was looking for an easy and cheap way to setup a java application (in this case Pentaho's Carte) to run as a Windows service.  After reviewing a few options I went with "Yet Another Java Service Wrapper"
(YAJSW) which is based on Tanuki's Java Service Wrapper (JSW).  JSW is the basis, but the YAJSW spin off offers a LGPL  version for 64-bit Windows which JSW did not.

Be sure to reference the YAKSW web site for the installation details, but they are pretty straight forward:


  • Unpack the zip file to a folder <yajsw>.
  • Start the application you would like to wrap. NOTE: we need the pid of the application not the batch file which started the application.
  • Goto yajsw/bat and execute genConfig.bat <pid>
  • Edit the wrapper.conf in YAJSW conf folder to give the service a meaningful name.  For example:
    • wrapper.ntservice.displayname=PDI Carte
    • wrapper.ntservice.description=Carte is a simple web server that allows you to execute transformations and jobs remotely
  • Execute your wrapped application as console application by calling: runConsole.bat
  • 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

I was concerned about handling application upgrades without breaking the service so I placed the application in a non-version specific folder. eg. pdi as opposed to pdi-ce-4.3.0.  I also put the YAJSW directory in the same parent folder as the application and give it a name to show it is the service for pdi, so pdi-service.  Now to perform upgrade I do the following:

  • stop the service: pdi-service\bat\stopService.bat
  • To uninstall the service: pdi-service\bat\uninstallService.bat
  • Rename pdi to pdi-old
  • Create a new pdi fodler
  • Copy the enw application into the new pdi folder
  • Reinstall the service: pdi-service\bat\installService.bat
  • Restart the service: pdi-service\bat\startService.bat

Note 1: That when you reinstall the service it will be set to start automatically, so if that is not the desired setup you'll need to go into Control Panel -> Administrative Tools -> Service and find the yajsw service and change it's start up option.

Note 2: These upgrade steps may be overkill, but so far they seem to work.  I'll update the instructions if I find a better way.

Note 3: If you upgrade java (eg. 1.6 to1.7) then you'll likely need to reconfigure the service since it references the java path, in my case c:\Program Files\Java\jre6

I couldn't find the author's name, but YAJSW seems like a great app, THANK YOU!

This entry was posted in Windoze. Bookmark the permalink.

One Response to Java Apps as Windows Service

  1. todd says:

    The more I think about it, I may leave the application folder name alone (pdi-ce-4.3.0) and do an uninstall of the service for the old  version and reinstall of the new version.  The service is easy enough setup that the loss of application version tracking and fallback isn't with the slightly faster process.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.