开发者

How can I set the http proxy in eclipse?

I have code that needs to make an outbound http connection. However, I am behind a proxy. I have seen examples of how to set th开发者_如何学Goe proxy parameters, but none of which allow me to specify my username and password.

Has anyone got an example to help me out?


  1. [Windows] -> [Preferences] -> [General] -> [Network Connections]
  2. Set Active Provider to "Manual"
  3. Select protocol (HTTP)
  4. Click Edit
  5. Click "Requires Authentication"
  6. Provide creds


Here is a reference on configuration proxy information for any Java app. If you are running your app from Eclipse, you will want to set these in your launch configuration.

http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html


Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("30.40.50.60", 8080));
URL url = new URL("http://www.somewebsite.com");
HttpURLConnection uc = (HttpURLConnection)url.openConnection(proxy);


I ended up using Apache HttpClient - http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientProxyAuthentication.java


You can find this under Run->Run Configurations or Run->Debug Configurations, under the “Target” tab. You’re looking for the “Additional Emulator Command Line Options” box. In my case, the full string I used was -http-proxy http://username:password@10.0.0.1:3128 where username is my proxy login, password is my proxy password, 10.0.0.1 is my proxy IP address, 3128 is the port.

emulator settings from within the emulator. I have no idea why this is necessary but it didn’t work without this change. Once you launch the emulator, go to Settings->Wireless & Networks->Mobile Networks->Access Point Names->TelKila and set “Proxy” and “Port” to match the settings above

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜