Search code examples
javawindows-services

Wrapping JAR as NT Service without access to target systems


I have a Java application packaged as runnable JAR which I need to install on end users Windows machines.

The application must be resilient and unobtrusive, I could only provide a link for the users, and they would expect to download and install it(the Windows way, like with NSIS). After installation it should run automatically as Windows Service, which must be autoconfigured to restart on failure.

I investigated these wrapper frameworks:

Does any one of them support my scenario, or could be integrated with install system to complete it?

If there is no way to achieve this, I could fallback to these options:

  • Rewrite the application with .NET or C(Windows API) which have native integration with the services facility.
  • Provide the runnable JAR for download and tell the users to put it in the Startup folder(similar effect).

What would you suggest?


Solution

  • I just wrapped the JAR into a Windows executable with Launch4j's Maven plugin.

    Then the executable was distributed to the end users to their Windows Startup folders, and when combined with Launch4j's option to auto-restart on crash removed the need to run the program as Windows Service.