I tried searching for this error. There are many results on google for this search but nothing proved useful to me. This is my web service method
@GET
@Path("/values")
public String test() {
    return "{\"x\":5,\"y\":6}";
}
This is my client code
public class Check {
public static void main(String[] args){
    String url = "http://localhost:8181/math/webapi/values";
    HttpClient httpClient = HttpClientBuilder.create().build();
    HttpGet request = new HttpGet(url);
    try {
        HttpResponse response = httpClient.execute(request);
        String value = response.toString();
        JSONObject json = new JSONObject(value);
        int i = json.getInt("x");
        System.out.println(i);
    }catch (Exception e) {
        e.printStackTrace();
    }       
}
The above code is a starter code and it is for learning how to use it. If this is solved, I have to apply the knowledge in another application. The client side code, I want to use the logic in android.
EDIT
public class Check {
public static void main(String[] args){
    String url = "http://localhost:8181/math/webapi/values";
    HttpClient httpClient = HttpClientBuilder.create().build();
    HttpGet request = new HttpGet(url);
    try {
        HttpResponse response = httpClient.execute(request);
        InputStream value = response.getEntity().getContent();
        BufferedReader br = new BufferedReader(new InputStreamReader(value));
        String jsonValue = br.readLine();
        JSONObject json = new JSONObject(jsonValue);
        int i = json.getInt("x");
        System.out.println(i);
    }catch (Exception e) {
        e.printStackTrace();
    }       
}
 
     
    