You cannot run classes that are part of the Android platform (e.g. HttpClient ) in the REPL, because the methods in android.jar are all stubs. The actual implementation of these methods is on your phone or emulator, so you will need to run the emulator at least.
See Making an Apache DefaultHttpClient Call in "java.lang.RuntimeException: Stub!" for more details.
For example, if you run the code sent to the REPL, you will get a RuntimeException similar to the following:
java.lang.RuntimeException: Stub! at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:5) at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:7) at CodeSnippet_10.run(CodeSnippet_10.java:7) at org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain1.eval(ScrapbookMain1.java:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain.evalLoop(ScrapbookMain.java:54) at org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain.main(ScrapbookMain.java:35)
If you want to test this yourself, create a new Java project in Eclipse, and then create a new scrapbook page in your project ( File > New > Other... > Java Run/Debug > Scrapbook Page ). Add android.jar to the build path of the project, then right-click the scrapbook page, select Set Imports and import the org.apache.http.* Package. When you execute a snippet (Ctrl + U), you will get an exception similar to the one I wrote above.
source share