Jersey 2

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.

  1. 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.

    Jersey2 RESTful Web Service Java Maven Project

  2. 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.

    Jersey2 Console Result

    So here we are done with the first program with Jersey 2 RESTful Web Services in Java.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.