1. Add jersey-server maven dependency to your Java Project

<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-server</artifactId>
    <version>1.19</version>
    <scope>compile</scope>
</dependency>

2. Run your test server

public static void main(String[] args) {
        HttpServer server;
        try {
            /**
             * start jersey server.
             */
            server = HttpServerFactory.create("http://localhost:8042/");
            server.start();
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        } catch (IOException e) {
            System.out.println(e.getMessage());
        }
    }

3. Created Resource class with REST methods is added to the server automatically

@Path("/") public class TestResource {

@GET
@Produces(MediaType.APPLICATION_JSON)
public Response testMethod(){

...