Configure Java Applications To Use The Proxy Server

To access external websites from a java application you must configure the java.net classes to connect through our proxy server. All that is required is to set the proxy server host name and port as system properties.

For example, the code fragment below will set the proxy values.

Properties properties = System.getProperties();
properties.put("http.proxyHost","webcache");
properties.put("http.proxyPort","3128");

Note: You can also pass system properties on the command line using -D options to java (see man java for more information).

A very simple example application is provided here

More Information

Java Tutorial - Networking