Q:

the method addHeader (String, String) is undefined for the type HttpGet

I have this program:
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;

public class ApplicationRESTFul {

    public static void main(String[] args) {

        String url = "http://www.google.com/search?q=httpClient";

        HttpClient client = HttpClientBuilder.create().build();
        HttpGet request = new HttpGet(url);

        request.addHeader("Accept", "application/json");

    }

}

But I got this message from eclipse
the method addHeader (String, String) is undefined for the type HttpGet

I am using this library and as I see in the documentation , the method should exist (org.apache.httpcomponents.httpclient_4.5)
http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/HttpGet.html

A:

I solved it by adding httpcore JAR to class path. Adding the dependency from maven adds the httpcore JAR too and not just the httpclient JAR, and that's why it works too.

A:

importing the depency from maven instead to add the lib in the classpath solved the problem
 <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.6</version>
        </dependency>  

