Sometimes you just need to create a quick little webservice. I perfer writing most of my projects in Java because of its cross-platform, ease of debugging, and robustness. So here is some tips on starting a new java webservice using Maven and Jetty.
First, if you dont already have Maven installed:
[code]sudo apt-get install maven[/code]
Start by creating a new project directory. Maven will actually generate a template project directory for you.
mvn archetype:generate \
This will create a standard java webapp project. Now, the standard way to deploy java webapps would be to create a war and deploy it on a java webserver like tomcat or glassfish. But because this is just a quick, standalone, webapp project, it doesnt need to be deployed. It can run just fine by itself. After you run
mvn package, there will be a [projectdir]/target/bin/[project] for you to run to start the standalong webapp. By the way, you can still create a war and deploy to a webserver by running
Another thing you can do all the shade plugin to your project have Maven create one ‘uber’ jar that contains all the project dependencies. It’s nice and convient because at the end of the day, its real easy to just run
java -jar myproject.jar