Configuring Jetty as a Windows service

Here’s a quick guide for setting Jetty 7 up as a Windows service. It depends on Apache Commons Daemon for installation and configuration.

Note: This solution is not required when using Jetty 6. It includes its own Win32Wrapper (some limitations on 64-bit AMD) .

The following tiny scrips can be used for setting up the service. After the service is installed, the most convenient way to manage it is to start ‘Monitor service’ which gives you a gui for configuring options.

rem Install service
<path-to-commons-daemon>\prunsrv.exe //IS//Lift ^
  --DisplayName="Lift" ^
  --Install=<path-to-commons-daemon>\prunsrv.exe ^
  --StartMode=jvm
rem Update service
rem  - using 64-bit server version of JVM
<path-to-commons-daemon>\prunsrv.exe //US//Lift ^
  --Jvm="c:\program files\java\jre6\bin\server\jvm.dll" ^
  --Environment=jetty.port=80;jetty.host=<host-ip> ^
  --Classpath=%CLASSPATH%;<path-to-jetty>\start.jar ^
  --StartParams="--daemon" ^
  --StopParams="--stop" ^
  --StartClass=org.eclipse.jetty.start.Main ^
  --StartPath=<path-to-jetty> ^
  --StopClass=org.eclipse.jetty.start.Main ^
  --StopPath=<pathto-jetty> ^
  --LogPath=<path-to-logs>
rem Monitor service
<path-to-commons-daemon>\prunmgr.exe //MS//Lift
rem Uninstall service
<path-to-commons-daemon>\prunsrv.exe //DS//Lift
rem Start service
<path-to-commons-daemon>\prunsrv.exe //TS//Lift
rem Stop service
<path-to-commons-daemon>\prunsrv.exe //SS//Lift

See http://commons.apache.org/daemon/procrun.html for all scripting options.