You probably cannot access the Internet because you are behind a proxy server.
The proxy setting for Jsoup is the same as for regular connection URL in Java .
Given that your proxy server is at 127.0.0.1 and its port is 8182 , you can set it as:
System.setProperty("http.proxyHost", "127.0.0.1"); System.setProperty("http.proxyPort", "8182");
If you are trying to access via HTTPS, then the properties are https.proxyHost and https.proxyPort .
See a working example:
import org.jsoup.Jsoup; import org.jsoup.nodes.Document; public class ExampleJSoupProxy { public static void main(String[] args) throws Exception { System.setProperty("http.proxyHost", "127.0.0.1"); System.setProperty("http.proxyPort", "8182"); Document doc = Jsoup.connect("http://stackoverflow.com").get(); System.out.println("Obtained Title: " + doc.title()); } }
Output:
Obtained Title: Stack Overflow
source share