Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple and flexible method to run java as a windows service

I read SO q&a about launch java as windows service wrappers, but can't find/choose product, suitable for my requirements :

  1. Wrapper reads all java launch parameters from config file. In registry must be only commands to run wrapper itself - path to exe and maybe path to config. Always grant admin rights to change app parameters in registry is not comfortable.

  2. Working dir and path to application also must be in config. I want to place all wrapper files deep into program, because user not intrested in it.

  3. No dependencies(.net, python, etc). I don't want to extend requirements of my program.

  4. Free for every windows OS, include win64.

  5. Simple and lightweight. Size of my program with all 3rd party jars is 12Mbytes. I don't want to add 20Mbytes wrapper.

  6. Automaticaly restart if app process dies.

  7. Preferably single exe files for all windows platform.

I try and lookinkg throught different wrappers and tired a bit. Best suitable till now is:

  1. jslwin (http://jslwin.sourceforge.net), but i don't know how mature it is(version 0.99). Also parameter lists in config is a bit complex(need to edit parameters quantity).
  2. winrun4j (http://winrun4j.sourceforge.net), but i don't know how mature it is(version 0.45). Also it needs a special class for working as a service.

Also i try or look throught:

  1. YAJWS (http://yajsw.sourceforge.net/) too big (30mb), can't make it work with custom files layout.
  2. Advanced Installer (http://www.advancedinstaller.com) too big (50mb).
  3. nssm (http://nssm.cc/) store launch parameters in registry(no config)
  4. winsw (https://kenai.com/projects/winsw) .net required, stops after process dies
  5. commons-daemon, procrun (http://commons.apache.org/proper/commons-daemon/index.html) store launch parameters in registry(no config), can't understand this product, i think it's complex.
  6. jsmooth (http://jsmooth.sourceforge.net) complex and old(last update 2007)
  7. javaservice (http://forge.ow2.org/projects/javaservice/) old (last update 2006)
  8. runasservice (http://runasservice.sourceforge.net/) requires .net
  9. windows rktools - sc, instsrv, srvany (http://support.microsoft.com/?scid=kb%3Ben-us%3B137890&x=16&y=7) - store launch parameters in registry(no config)
  10. jwrapper (http://www.jwrapper.com/) seems not what i need. It packs java program in exe file with JRE. It's not about windows services.
  11. firedaemon (http://www.firedaemon.com/) not free. And maybe it's not what i need.
  12. launch4j (http://launch4j.sourceforge.net/) cool ability "search or download java". Maybe i add something like this to simplify installation, but it is still not about subj.
  13. Java service wrapper (http://wrapper.tanukisoftware.com/) not free for win64.

Tell me please which wrappers suits my needs? Or maybe i think wrong about wrappers above and some of them suits my needs to?

like image 742
cynepnaxa Avatar asked Apr 08 '14 08:04

cynepnaxa


1 Answers

I have had similar issues over the years. Its not that they all are inferior, its that they are all pretty hard to integrate nicely with your own project.

You may want to check out stork: https://github.com/fizzed/stork

It'll help create launchers for your Java console or daemon apps, and they will work across all major platforms. There is also a maven plugin in case you wanted to tie it into your existing build process.

like image 90
Wolverine Avatar answered Sep 30 '22 14:09

Wolverine