I\'ve just inherited a java application that needs to be installed as a service on XP and vista. It\'s been about 8 years since I\'ve used windows in any form and I\'ve neve
I've had some luck with the Java Service Wrapper
With Apache Commons Daemon you can now have a custom executable name and icon! You can also get a custom Windows tray monitor with your own name and icon!
I now have my service running with my own name and icon (prunsrv.exe), and the system tray monitor (prunmgr.exe) also has my own custom name and icon!
MyServiceName.exe
and MyServiceNamew.exe
respectively.Download WinRun4J and use the RCEDIT.exe
program that comes with it to modify the Apache executable to embed your own custom icon like this:
> RCEDIT.exe /I MyServiceName.exe customIcon.ico
> RCEDIT.exe /I MyServiceNamew.exe customTrayIcon.ico
Now install your Windows service like this (see documentation for more details and options):
> MyServiceName.exe //IS//MyServiceName \
--Install="C:\path-to\MyServiceName.exe" \
--Jvm=auto --Startup=auto --StartMode=jvm \
--Classpath="C:\path-to\MyJarWithClassWithMainMethod.jar" \
--StartClass=com.mydomain.MyClassWithMainMethod
Now you have a Windows service of your Jar that will run with your own icon and name! You can also launch the monitor file and it will run in the system tray with your own icon and name.
I am currently requiring this to run an Eclipse-based application but I need to set some variables first that is local to that application. sc.exe will only allow executables but not scripts so I turned to autoexnt.exe which is part of the Windows 2003 resource kit. It restricts the service to a single batch file but I only need one batch script to be converted into a service.
ciao!
A pretty good comparison of different solutions is available at : http://yajsw.sourceforge.net/#mozTocId284533
Personally like launch4j
I didn't like the licensing for the Java Service Wrapper. I went with ActiveState Perl to write a service that does the work.
I thought about writing a service in C#, but my time constraints were too tight.
One more option is WinRun4J. This is a configurable java launcher that doubles as a windows service host (both 32 and 64 bit versions). It is open source and there are no restrictions on its use.
(full disclosure: I work on this project).