Archive for November, 2007

Java and HTTP Proxy Settings

How to connect to internet from Java program through a proxy? The answer is very simple Just add the following arguments to the virtual machine

java -Dhttp.proxyHost=hostname -Dhttp.proxyPort=port -Dhttp.proxyUser=username -Dhttp.proxyPassword=passowrd

or just put set these System properties using the code.

System.getProperties().put("http.proxyHost", "hostname");
System.getProperties().put("http.proxyPort", "port");
System.getProperties().put("http.proxyUser", "username");
[...]