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.
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
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With