Jersey 2: RESTful Web Services in Java is a really very good toolkit for RESTful Web Services. The Jersey 2 is open source, production quality framework for developing RESTful Web Services in Java that provides support for JAX-RS APIs.
In this post, we will see how we can execute a simple program for RESTful Web Service with Jersey 2. Refer.
- Prerequisite
Java must be installed first.
You will also need Maven Setup done already on your machine.
You will need an IDE like Eclipse to build and execute the project.
Find the Source Code on GitHub: RESTful Web Service using Jersey 2.
- Jersey 2: RESTful Web Service Program
Once above pre-requisites are done, either use the GitHub project to clone and execute Jersey 2 Sample Program. Or Create Sample program with instructions below.
-
Once the JDK and Maven setup is done. In any of the empty directory checkout the Git project for Jersey2. This will be your workspace with eclipse to execute or modify the Jersey 2 RESTful Web Services Java Source code.
-
The Jersey2 program will be created in Eclipse and it will have /src/main/java/ folder for writing java source code.
Now, run the Maven command from this Project folder to build the project, mvn clean install.
And then, run the Jersey2 program by executing the Program in web server i.e for example Tomcat. This will give you the result on a console and in the browser as below.
Then use the URL
http://localhost:8080/RESTJerseyHelloWorld/rest/hello/WelcomeToJersey2 to execute and see the result on browser. Considering that Web server like tomcat with default port as 8080.So here we are done with the first program with Jersey 2 RESTful Web Services in Java.