dcsimg

How can I make URL connections through a proxy server?

John Zukowski

Java uses two system properties to designate a proxy: http.proxyHost and http.proxyPort. For applets, these are automatically set to use the browser's settings. However, in an application you need to set them yourself:

Properties props = System.getProperties();
props.put("http.proxyHost", "proxyhostname");
props.put("http.proxyPort", "proxyhostport");