Run Java Applications as Windows Services - Java Service Wrapper

March 10
blog author

Appno Blogger

Appnovation Coop

While we are developing various Java applications, sometimes we need to run them in Windows Services or Unix Daemons so that they can be automatically started at boot time and run in the background. One of the big advantages of doing this is that the application will be invisible because it runs in the background and therefore you can avoid the possibility of the application getting terminated by closing the application console.

There are many tools to achieve this such as "FireDaemon" or "AlwaysUp" but the easiest and nicest tool I have found, of course it is open source, is Java Service Wrapper which is developed by The Java Service Wrapper is an excellent open source set of programs that allow you to turn your Java applications into Windows Services and therefore the applications can start automatically without someone having to log on. It also adds advanced failover, error recovery, and analysis features to make sure that the application has the maximum possible uptime. I don't want to explain all the detailed steps to configure the Java Service Wrapper to run a Java application as a service/daemon because has already posted very detail instructions about this to their website so you can get them from here.

But in summary, the main step is to edit wrapper.conf which is stored under the "conf" folder and these following configuration directives should be updated based on your environments and Java application. path to your java.exe specifies the name of the class what will be instantiated by wrapper.exe. This class must contain a main method and must implement WrapperListener. 1 specifies the location of the java archives that you want to load 1 specifies the metadata source configuration file, which specifies the location of the deployment configuration for remote foundation services. 1 specifies additional java parameters. specifies the service name on Windows when an application is installed wrapper.ntservice.displayname display name of Windows Service when an application is installed wrapper.ntservice.description specifies the service description on Windows when a application is installed. For more information for the Java Service Wrapper, refer to this page. And note that currently, the Java Service Wrapper supports both 32-bit and 64-bit but the JSW for 64-bit is not free. But no worries, there is another service wrapper "Yet Another Java Service Wrapper" which is a java centric implementation of the Java Service Wrapper and you can get more information about this here.