Create Simple Java RESTful Web Services Using Jersey

By | June 10, 2016

In this tutorial you will learn how to create simple Java RESTful web services using Jersey framework.

JAX-RS is the Java API used for creating RESTful web services. There are mainly two types of implementation of JAX-RS that are Jersey and RESTeasy. In this tutorial we will see Jersey implementation.

We will use eclipse to create our web service. Make sure it contains apache tomcat server. You can follow below link to know how to download and configure tomcat.

Read: Configure Apache Tomcat Server in Eclipse IDE

Create Simple Java RESTful Web Services Using Jersey 1

Also Read: Create Java SOAP Web Service Using Eclipse

How to Create Java RESTful Web Services Using Jersey Framework

1. First of all download the Jersey jars from below link.

2. Open eclipse and go to File -> New -> Dynamic Web Project to create a dynamic web project with name JavaRESTfullWS.

3. Now we have to import jersey jars in our project. The file that you have downloaded in previous step is compressed file. After extracting it you will get several folders. Just import all the jars present in those folders. You can follow below link if you don’t know how to import jars in eclipse.

4. Create a package with name example under src folder in your project. Under this package create a source file with name DemoService and add following code inside it.


5. Enter following code in web.xml file. You can find it under Web-Content -> WEB-INF folder. If it is not there then create one.



The project has following structure.

Create Simple Java RESTful Web Services Using Jersey 2
6. Right click on your project folder and then select Run As -> Run on Server.

7. For testing the web service open following url in browser.


Create Simple Java RESTful Web Services Using Jersey 3

You can change Hello at the end of the url to pass some other message as parameter.

Video Tutorial

You can watch below video. Everything is explained in it step by step.

Comment below if you are facing any difficulty to create Java RESTful web services.

Happy Coding!! 🙂 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *