How to install a java application as a windows service.
At work we had a java application that was written for us. The application needed to run as a windows service so that it would run on the server without the need for a user to log in. It took me awhile to figure it out, as there was not one spot with all the information I needed. Here’s how I did it, your mileage may vary!
This was compiled with references from MS using the Windows Server 2003 Resource Kit Tools, you can use the resource kit appropriate to your server install. The only files needed from the resource kit are the instsrv.exe and the srvany.exe files. These can be found on the internet, but for a corporate server install I thought it was best to download the kit from Microsoft.
Now to the steps:
- Use instsrv.exe to install srvany.exe as the service, from the command line: <path>\<to>\instsrv.exe <application_name> <path>\<to>\srvany.exe.
- Run regedit and Find: My Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\<application_name>
- Select the <application_name> and select “Edit..”, “New…”, “Key“.
- Name the key Parameters.
- Select the Parameters key that you have created, and select “Edit…”, “New…“, “String Value“.
- The Name should be Application.
- Double click the name to open a dialog in which you can enter the value <path>\<to>\<jre>\javaw.exe.
- Select “Edit…”, “New…“, “String Value“
- The Name should be AppDirectory.
- Double click the name to open a dialog in which you can enter the value <path>\<to>\<java class files>.
- Select “Edit…“, “New…“, “String Value“.
- The Name should be AppParameters.
- Double click the name to open a dialog in which you can enter the value -Xrs <application_name>
IMPORTANT! : the -Xrs must be in the AppParamenter name.
Notes: Ensure the service is set to “Log on” as a Local System Account, and the “Interact with desktop” is unchecked.
This is how I did it. The most important part was using the -Xrs value. It would not work at all until that value was set.
Comments or Questions?

