Jetty Hello World Eclipse
If you have just stared with Jetty want to have a quick look how it works with Eclipse please follow steps below:
- Create maven project name: JettyHelloWold (If you are not sure how to create maven project in eclipse please follow steps from this tutorial http://javahonk.com/create-maven-project-eclipse
- Below is sample default project structure that can be download from link mentioned in the bottom of this page:
- Add below dependencies in pom.xml:
- By default maven search settings.xml in C:\Users\user_name\.m2 directory please add below setting.xml file in this directory:
Note: Only below extra pluginGroups you will have to add in default settings.xml file because when you run jetty command it searches this plugin group:
- To run jetty from command prompt you will have to set up JAVA_HOME,M2_HOME and path to environment variable.
Note: As you see below we are setting these in User Variables not System Variable because if you are working in big company they give admin permission to local computer so that you can not change environment system variable.
- Once all setup is done go to command prompt and type “mvn jetty:run” command:
- You will see below on console:
- As you see above server started on localhost at port 8080 where application is accessible. Type below in browser you will see result:
Download Project: JettyHelloWorld