Free tutorials for Java, Eclipse and Web programming



Follow me on twitter

4. Proxy

You can define a proxy at startup via a start parameter.

			
java  -Dhttp.proxyHost=proxy  -Dhttp.proxyPort=8080 JavaProgram

		

In your code you can set a proxy via System.setProperty. For example if your proxy is called "proxy" and runs on port "8080" the following code will set the proxy.

			
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "proxy");
System.setProperty("http.proxyPort", "8080");