Are you on the urge to implement or start developing RESTful web services with Java?
You are at the right place…
Ok. Start your timer and we will finish the whole exercise in 15 minutes. I assume you have already installed Java, Maven in your system.
To start off with, you first execute the following Maven command in the console of your choice.
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false -DgroupId=<groupid> -DartifactId=<artifactid> -Dpackage=<package-name> -DarchetypeVersion=2.19
NOTE: Change groupid, artifactid and package-name
Something like this,
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false -DgroupId=com.cloudskol -DartifactId=restful -Dpackage=com.cloudskol.restful -DarchetypeVersion=2.19
After you execute the above command you will see the project skeleton is created like below.
Hurrah! 50% work is done!
Our next goal is to compile and run our application.
Compile and Package:
Navigate inside our newly created project folder and execute the command
mvn clean package
Take the generated war file, and put it inside any Java web container and run your web server. Hit http://localhost:8080/restful into your browser and you will see the output in your browser.
STOP! I hope we have NOT yet completed the 15 minutes timings.
Yeah! we are done with our first RESTful web service implementation with Java.