Hello My dear fellow Java Developer friends, Today I want to share with you one of the problem that I faced, and how I solved it. I was assigned to look for a better way to stop a Jetty server. We were stopping jetty by hitting ctrl + C or killing the process from the task manager. I have been searching the web for the solution : How to stop it from command prompt with no luck. Finally with one of our fellow blogger's post (read it here ), where he explained how Jetty can be started and stopped through an ant script, I was able to find a way to stop it using command prompt.
In order to start Jetty (which we all know) people usually use the following command:
java -jar start.jar (assuming you are dealing with Jetty7 eclipse version) However, if you want to be able to stop the jetty server from command prompt, you have to pass two extra jvm properties while starting, such as:
java -DSTOP.PORT=8079 -DSTOP.KEY=secret -jar start.jar
In order to stop Jetty :
java -DSTOP.PORT=8079 -DSTOP.KEY=secret -jar start.jar - –stop (Given the fact that you have used same jvm argument while starting that jetty server)
I hope those of you who are searching the way to stop jetty from command prompt, this post will save you some time.