I am using HttpClient components from Apache for the following simple program and I see the below exception:
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.(DefaultHttpRequestWriterFactory.java:52) at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.(DefaultHttpRequestWriterFactory.java:56) at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.(DefaultHttpRequestWriterFactory.java:46) at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.(ManagedHttpClientConnectionFactory.java:72) at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.(ManagedHttpClientConnectionFactory.java:84) at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.(ManagedHttpClientConnectionFactory.java:59) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.(PoolingHttpClientConnectionManager.java:487) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:147) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:136) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:112) at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:726) at com.starwood.rms.controller.property.HttpExample.main(HttpExample.java:14)
public class HttpExample { public static void main(String[] args) { HttpClient client = HttpClientBuilder.create().build(); HttpGet request = new HttpGet("https://www.google.com/?q=java"); try { HttpResponse response = client.execute(request); System.out.println(response.getStatusLine()); } catch (Exception e) { e.printStackTrace(); } } }
I am using
- Httpclient-4.3.3.jar
- Httpcore-4.3.2.jar
Any ideas?