Make Jetty as Windows Service

Normally, we can start Jetty in the command prompt by

  • java -jar <Jetty_Home>/start.jar

In case you close the command prompt accidentally, Jetty will shutdown. One way to solve the problem in Windows platform is to make use of the Windows Service Wrapper provided by Jetty.

All u need for using the Windows Service Wrapper are

  • <Jetty_Home>/bin/Jetty-Service.exe
  • <Jetty_Home>/bin/jetty-service.conf
  • <Jetty_Home>/etc/jetty-win32-service.xml
  • <Jetty_Home>/lib/win32

You can configure the class paths and log file path inside the jetty-service.conf

wrapper.java.classpath.1=../lib/win32/*.jar
wrapper.java.classpath.2=../lib/*.jar
wrapper.java.classpath.3=../start.jar
wrapper.java.library.path.1=../lib/win32/
wrapper.java.additional.1=-Djetty.home=../
wrapper.java.additional.2=-Djetty.logs=../logs
wrapper.java.initmemory=3
wrapper.java.maxmemory=64
wrapper.java.mainclass=org.mortbay.jetty.win32service.JettyServiceWrapperListener
wrapper.app.parameter.1=../etc/jetty.xml
wrapper.console.format=PM
wrapper.console.loglevel=INFO
wrapper.logfile=../logs/jetty-service.log
wrapper.logfile.format=LPTM
wrapper.logfile.loglevel=INFO
wrapper.logfile.maxsize=0
wrapper.logfile.maxfiles=0
wrapper.syslog.loglevel=NONE
wrapper.ntservice.name=Jetty
wrapper.ntservice.displayname=Jetty6-Service
wrapper.ntservice.description=Jetty is an open-source, standards-based, full-featured web server implemented entirely in java
wrapper.ntservice.starttype=AUTO_START
wrapper.ntservice.interactive=false

wrapper.filter.trigger.1=java.lang.OutOfMemoryError
wrapper.filter.action.1=RESTART

 

Install Jetty as Windows Service

Jetty-Service.exe --install jetty-service.conf
#or
Jetty-Service.exe -i jetty-service.conf

Start the Jetty Windows Service

Jetty-Service.exe --start jetty-service.conf
#or
Jetty-Service.exe -t jetty-service.conf

Stop the Jetty Windows Service

Jetty-Service.exe --stop jetty-service.conf
#or
Jetty-Service.exe -p jetty-service.conf

Remove Jetty the Windows Service

Jetty-Service.exe --remove jetty-service.conf
#or
Jetty-Service.exe -r jetty-service.conf

Done =)

Reference: Jetty – Win32Wrapper

Advertisement

8 thoughts on “Make Jetty as Windows Service”

  1. I am having trouble to execute
    Jetty-Service.exe –install jetty-service.conf
    in my cmd-Window.

    I unzipped my wrapper windows x86 64 3 5 10 st to
    C:\>

    So I opened the Cmd as an Admin and wen to the folder
    C:\>wrapper windows x86 64 3 5 10 st to
    then I put
    Jetty-Service.exe –install jetty-service.conf
    but cannot execute it?

    can you please help me out here?

    Like

  2. Mind the double -- in combination with install (so -- install or -i)
    so the correct command is :
    jetty-service.exe --install jetty-service.conf

    or
    jetty-service.exe -i jetty-service.conf

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.