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 !!

Was this post helpful?

Join 7000+ Awesome Developers

Get the latest updates from industry, awesome resources, blog updates and much more.

* We do not spam !!

3 thoughts on “Jersey Hello World Example”

  1. There is no explanation about classes and how the Web services works. I faced questions like How web services works internally , I tis dfficult to find answer of this questionson internet 🙁 , can you please help on this


Leave a Comment


A blog about Java and related technologies, the best practices, algorithms, and interview questions.