L'Authentification de base avec RestTemplate - erreur de compilation - Le constructeur HttpClient() n'est pas visible

d'essayer d'ajouter l'authentification basique à restTemplate

problème que je rencontre est que je ne peux pas initialiser : (avec les importations dans l'extrait de code)

HttpClient client = new HttpClient();

Ce code résout une erreur de compilation (avec aucune suggestion disponible à partir d'eclipse pour résoudre ce problème)

1) quel est le problème ?

2) Suis-je importer la mauvaise catégorie ?

mon extrait de code :

import org.apache.http.client.HttpClient;
//OR (not together)
import sun.net.www.http.HttpClient;


HttpClient client = new HttpClient(); //this line dosent compile
UsernamePasswordCredentials credentials =
new UsernamePasswordCredentials("USERNAME","PASS");
client.getState().setCredentials(
  new AuthScope("www.example.com", 9090, AuthScope.ANY_REALM),
  credentials);
CommonsClientHttpRequestFactory commons =
     new CommonsClientHttpRequestFactory(client);

RestTemplate template = new RestTemplate(commons);
SomeObject result = template.getForObject(
     "http://www.example.com:9090/",SomeObject.class
 );

L'exécution de cet accès à l'Exception :

> failed due to an unhandled exception: java.lang.Error: Unresolved
> compilation problems:     The constructor HttpClient() is not visible
>   The method getState() is undefined for the type HttpClient
>   CommonsClientHttpRequestFactory cannot be resolved to a type
>   CommonsClientHttpRequestFactory cannot be resolved to a type
>   SomeObject cannot be resolved to a type     The method
> getForObject(String, Class<SomeObject>, Object...) from the type
> RestTemplate refers to the missing type SomeObject    SomeObject cannot
> be resolved to a type

OriginalL'auteur Nimrod007 | 2013-03-17