Jersey Hello World Example

I have written a number of posts on JAX-RS RESTEasy concepts and how to. Now I have started exploring Jersey which is another popular framework for making RESTFul applications. To start with, I am writing my hello world application in this post, which I will modify in next posts to show demos of other features Jersey provide.

Step 1) Make a eclipse web project using maven

Learn to make eclipse maven project here

Step 2) Update Jersey dependencies in pom.xml file

<project xmlns="" xmlns:xsi=""
  <name>JerseyHelloWorld Maven Webapp</name>
			<name> Repository for Maven</name>

Step 3) Update web.xml file with servlet mapping to com.sun.jersey.spi.container.servlet.ServletContainer

 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "" >


  <display-name>Archetype Created Web Application</display-name>

Step 4) Write first REST service class

The service class will look like exactly as RESTEasy because of common annotations used from JAX-RS.



public class JerseyHelloWorldService
	public Response getMsg(@PathParam("message") String msg)
		String output = "Message requested : " + msg;
		//Simply return the parameter passed as message
		return Response.status(200).entity(output).build();

Test the application

To test the application type below URL in browser: http://localhost:8080/JerseyHelloWorld/rest-points/show-on-screen/HowToDoInJava_Dot_Com

This will call the REST API method in service class and print the message passed as path parameter.

Jersey hello world message
Jersey hello world message

To download source of above post, click below link.

Sourcecode Download

Happy Learning !!


Notify of
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.

Our Blogs

REST API Tutorial

Dark Mode

Dark Mode