5

I have downloaded the Jsoup jar and added it in the library. I have added the proxy settings in Eclipse. But when ever I try this in the code:

Document doc = Jsoup.connect("http://www.wikipedia.com").get();
it throws the following error:
Errorjava.net.ConnectException: Connection refused: connect

Can anyone help me figure out a solution? Is there a specific way to set the proxy (in case I am missing something). Attaching screenshot of the same. Any help/guidance will be highly appreciated.

Screenshot of the proxy setting in Eclipse

1

2 Answers 2

6

The proxy in Eclipse only sets it for connecting to update software, etc. It has nothing to do with the proxy used by your programs.

To set the proxy you can try:

System.setProperty("http.proxyHost", "proxy.xxx.com"); // or the IP
System.setProperty("http.proxyPort", "6050");
Document doc = Jsoup.connect("http://www.wikipedia.com").get();

Or simply set the System properties when executing your program:

-Dhttp.proxyHost=proxy.xxx.com -Dhttp.proxyPort=6050
1

why dont you try this, if this works fine then there is problem with your steps to set proxy

URL u =new URL("www.google.com");
    URLConnection usn=u.openConnection();
    usn.connect();

there is also a another constructor which has proxy as a parameter

 URLConnection usn=u.openConnection(your proxy)

Not the answer you're looking for? Browse other questions tagged or ask your own question.