Question

I'm implemeting a webclient to consume a RESTful webserv using a POST call.

I'm using Jersey API for it.

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;

public class MyJerseyClient {
  public void updateGame(String url) {
        Client client = Client.create();
        WebResource webResource = client.resource(url);

    ClientResponse response = webResource.type("application/json").post(ClientResponse.class);
    if (response.getStatus() != 200) {
        System.out.println("o/p >>  ERROR!!");
    } else {
        System.out.println(response.getEntity(String.class););
    }
  } 
}

I've imported external jars using Project > Properties > Java Build Path > Add External Jars. enter image description here

But still getting an error -

enter image description here

enter image description here

Can someone please point me what I might be missing here?

Was it helpful?

Solution

While the required jersey-client JAR file is in your build path, it doesnt appear to be on your client's runtime classpath.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top