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
Which Jetty version is it? I am looing at jetty 7.0, It doesnt have those files.
LikeLike
The post was written for Jetty 6. For Jetty 7, you can checkout the source code @ http://svn.codehaus.org/jetty/jetty/branches/jetty-7/jetty-win32/ and build it.
The following links also suggest using the Java Service Wrapper. but i haven’t tried that before.
StackOverflow – Running Jetty 7 as Windows Service
Hope this help =)
LikeLike
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?
LikeLike
What error did u get?
LikeLike
try run CMD as administrator.. work perfectly
LikeLike
thanks for your comment. =D
LikeLike
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
LikeLike
Thx =)
LikeLike