ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

What Is Jetty
Pages: 1, 2, 3, 4

The Executable JAR

If you embrace Jetty's XML to configure your own apps, you could end up with a lot of boilerplate code to load the config file and launch your stand-alone apps. You can use Jetty's executable start.jar to load the file for you, saving you even more code.



For example, you can load the Jetty-based service from Step2Driver using the following command line:

CLASSPATH= ...various Jetty JARs...
java \
   -Djetty.class.path=${CLASSPATH} \
   -jar <jetty install path>/start.jar \
   standalone.xml

Note that this call only loads the XML file to establish the container and listener. It, therefore, doesn't call the rest of the sample code that invokes the test URLs.

Conclusion

An embedded Jetty servlet container lets you web enable a Java app without having to package it as a formal web app. This opens up new possibilities for several disciplines, making Jetty a versatile addition to your toolbox.

There is certainly more to Jetty than I have written here. I encourage you to review the Jetty website for docs and sample code.

Resources

Q Ethan McCallum grew from curious child to curious adult, turning his passion for technology into a career.


Return to ONJava.com.