I am new to Jetty and client/server architectures.
I managed to write a jetty server in eclipse and it works.
But how I can stop a jetty server? I heard something about stop.jar and start.jar. Where I can find it? Is it integrated in jetty-all-jar?
The Jetty server can be stopped with ctrl+c in the terminal window.
BTW, as to your question in title: mvn jetty:stop fails for you (see also manual for stopPort and stopKey )? By the way. I solved my problem. after a little searching i got run-jetty-run (code.google.com/p/run-jetty-run) for eclipse.
The various jetty-all.jar
artifacts can be used for embedded jetty usage. If you decide to use this jar, you have to manage your own startup / shutdown.
Update: 2015 : As of Jetty 9, the use of jetty-all.jar
as a dependency is deprecated. This is because as of Jetty 9, it is now impossible to satisfy "all" of Jetty in a single aggregate jar. There are components of Jetty that cannot be included as they will cause problems with this aggregate jar. The future of Jetty, with HTTP/2 support, also makes this aggregate jar less useful as a dependency.
Typical Embedded Mode usage
The thread that starts the server:
Server server = new Server();
// various server configuration lines
// ...
// Start server (on current thread)
server.start();
// Have current thread wait till server is done running
server.join();
The other thread that tells the server to shutdown
// Have server stop running
server.stop();
At this point the original thread's wait on server.join();
is complete and that thread continues to run.
Standard Distribution Usage
If you use the standard distribution available from download.eclipse.org/jetty/ you have the start.jar
that can be used to start/stop jetty itself.
Once you have unpacked your jetty-distribution, you'll find a start.jar
in the top most directory. This can be used as the following.
The process that starts jetty:
$ java -jar start.jar STOP.PORT=28282 STOP.KEY=secret
The process that stops jetty:
$ java -jar start.jar STOP.PORT=28282 STOP.KEY=secret --stop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With