I'm new to Android programming. My requirement is to call an HTTP request via HttpClient. Below is the code :
public class ClientWithResponseHandler { public final static void main(String[] args) throws Exception {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://www.google.com/");
System.out.println("executing request " + httpget.getURI());
// Create a response handler
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httpget, responseHandler);
System.out.println(responseBody);
System.out.println("----------------------------------------");
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
}
}
After executing the above code as a Java Application i get the below error in the console.
#
A fatal error has been detected by the Java Runtime Environment:
#
Internal Error (classFileParser.cpp:3174), pid=7288, tid=7476
Error: ShouldNotReachHere()
#
JRE version: 6.0_20-b02
Java VM: Java HotSpot(TM) Client VM (16.3-b01 mixed mode windows-x86 )
An error report file with more information is saved as:
C:\Sandeep\eclipse\workspace\HelloWebService\hs_err_pid7288.log
#
If you would like to submit a bug report, please visit:
http://java.sun.com/webapps/bugreport/crash.jsp
#
Any idea what could be the problem
Regards Sandeep
See this question and my answer to that:
I got the same problem, but with alot of googling I found the answer! See this page
Quote from the link:
Try this, it worked for me.
In addition to what Fredrik said, consider using AndroidHttpClient instead of
DefaultHttpClient
on an Android.i removed the run configuration and created a new one again
Becase you use Java class, Eclipse think Project is Java not a Android. So,when you click "run", Eclipse will run as Java App. You should chick Run as->Android Application.