java-ee Simple Resource


First of all for a JAX-RS application must be set a base URI from which all the resources will be available. For that purpose the class must be extended and annotated with the annotation. The annotation accepts a string argument which defines the base URI.

public class JaxRsActivator extends Application {

     * JAX-RS root path.
    public static final String ROOT_PATH = "/api";


Resources are simple POJO classes which are annotated with the @Path annotation.


public class HelloWorldResource {
    public static final String MESSAGE = "Hello StackOverflow!";

    public String getHello() {
        return MESSAGE;

When a HTTP GET request is sent to /hello, the resource responds with a Hello StackOverflow! message.