title: Exception in thread "main" java.lang.Error: Unresolved compilation problems: The constructor HttpHeaders() is not visible
body: <p>i am trying to get data from a server and i need to show server certificate on for this work so i have included server certificate as below but iam getting below error:</p>
  
  <p>Exception in thread "main" java.lang.Error: Unresolved compilation problems: </p>
  
  <pre><code>The constructor HttpHeaders() is not visible
  
  The constructor HttpEntity&lt;String&gt;() is not visible
  </code></pre>
  
  <p>my pom file:</p>
  
  <pre><code>&lt;properties&gt;
    &lt;spring.version&gt;4.1.0.RELEASE&lt;/spring.version&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
  
  &lt;dependency&gt;
      &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
      &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
      &lt;version&gt;4.3.4&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.google.guava&lt;/groupId&gt;
      &lt;artifactId&gt;guava&lt;/artifactId&gt;
      &lt;version&gt;18.0&lt;/version&gt;
  &lt;/dependency&gt;
  
    &lt;/dependencies&gt;
  </code></pre>
  
  <p>my java file:</p>
  
  <pre><code>public static void main( String[] args ) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, KeyManagementException, UnrecoverableKeyException
      {
  
          KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
          keyStore.load(new FileInputStream("/Users/workspace/a/cert.cer"),
                  "password".toCharArray());
          SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
                  new SSLContextBuilder()
                          .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                          .loadKeyMaterial(keyStore, "changeit".toCharArray()).build());
          HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
          ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
                  httpClient);
          RestTemplate restTemplate = new RestTemplate(requestFactory);
          HttpHeaders headers = new HttpHeaders();
          headers.add("Content-Type", "application/xml");
          HttpEntity&lt;String&gt; entity = new HttpEntity&lt;String&gt;();
         ResponseEntity&lt;String&gt; response = restTemplate.exchange(
                  "https://www.example.com",
                  HttpMethod.GET, entity, String.class);
          System.out.println( "Hello World!" );
      }
  </code></pre>