102
votes

I really cant understand what really is jersey..

What I know is that Jax-RS is an API for building REST web services, and jersey? I got some information and all say the same: "jersey is an implementation of Jax-RS". But what it means?

If jax-rs is an API, why we need jersey for create a rest web service? Is jersey a couple of more libs to aim with jax-rs? if yes, jax-rs is an incomplete API?

5
Jersey in an implementation of the JAX-RS specificationBrian Roach
Jersey just a interface to use JAX-rs in more easier way. JAX-RS don't provided servlet but Jersey does. Jersey provides a library to implement Restful webservices in a Java servlet container, Jersey provides a servlet implementation which scans predefined classes to identify RESTful resources. In your web.xml configuration file your register this servlet for your web application.taymedee
JAX-RS is a specification (which basically tells what to implement/follow) and Jersey is an implementation (which means how those specifications should be implemented). We can have multiple implementations for a Specification. We have libs for JAX-RS because we can use JAX-RS API's in your code so that in future if you change your implementation (in this case Jersey to something else) you code will still work fine. You can relate it with your interface and implementation class.Vishal Akkalkote
@VishalAkkalkote Hello, I am trying to wrap my head around this. I use Websphere 8.5 at work, and I am trying to write REST services using JAX-RS, but all tutorials show JAX-RS with Jersy. Are you saying, I can write the same EXACT code and it will work even if I don't use Jersy lib?superPhreshHackerKid
@superPhreshHackerKid Yes. it should work provided you will use one of implementation of JAX-RS. e.g. Apache CXFVishal Akkalkote

5 Answers

103
votes

JAX-RS is an specification (just a definition) and Jersey is a JAX-RS implementation.

26
votes

Straight from the jersey site

Jersey framework is more than the JAX-RS Reference Implementation. Jersey provides its own API that extend the JAX-RS toolkit with additional features and utilities to further simplify RESTful service and client development. Jersey also exposes numerous extension SPIs so that developers may extend Jersey to best suit their needs.

5
votes

JAX-RS is an specification and Jersey is a JAX-RS implementation.- True

This can be understood relating it to OOPS principles JAX-RS is an Interface and Jersey is a class implementing that interface.

These Specification creates a STANDARD for developing and using the web services.

There are other JAX-RS implementations too like wink, RestEasy.

JAX-RS is a specification which specifies how can we implement the web services,that what would be input type, input format, output type, its format, its configuration etc.Its Just a type declaration and its implementation are these libraries, Jersey, wink RestEasy etc.

Further, Java also have specification like JPA(Java Persistence API) and like mentioned above there is Hibernate which is an implementation of JPA.

3
votes

JAX-RS is an specification (just a definition) and Jersey is a JAX-RS implementation. Jersey framework is more than the JAX-RS Reference Implementation. Jersey provides its own API that extend the JAX-RS toolkit with additional features and utilities to further simplify RESTful service and client development.

2
votes

Using JAX-RS alone can not implement REST, need to register Jersey as the servlet dispatcher for REST requests on web.xml

A standard and portable JAX-RS API has been designed. Jersey RESTful Web Services framework is open source, production quality, framework for developing RESTful Web Services in Java that provides support for JAX-RS APIs and serves as a JAX-RS (JSR 311 & JSR 339) Reference Implementation.

Jersey framework is more than the JAX-RS Reference Implementation. Jersey provides it’s own API that extend the JAX-RS toolkit with additional features and utilities to further simplify RESTful service and client development. Source

For more

Restlet and Jersey are two of the most popular implementation of JAX-RS used for developing RESTful web services in Java ecosystem but there are a couple of other implementation also exist e.g. Apache Wink, Apache CXF, and JBoss RESTEasy. Source