There are 2 main ways to set/configure http proxy in your java application.
Example of using code to configure proxy setting on java
There are other proxy settings that you can set as well such as https, ftp, socks.
More resources:
http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html
- As a command line option when invoking the VM
- Using the System.setProperty(String, String) in your code
- http.proxyHost: the host name of the proxy server
- http.proxyPort: the port number, the default value being 80
- http.nonProxyHosts: a list of hosts that should be reached directly, bypassing the proxy
java -Dhttp.proxyHost=webcache.mydomain.com -Dhttp.proxyPort=8080
-Dhttp.noProxyHosts=”localhost|host.mydomain.com” YourAppMainClass
Example of using code to configure proxy setting on java
//Set the http proxy to webcache.mydomain.com:8080
System.setProperty("http.proxyHost", "webcache.mydomain.com");
System.setPropery("http.proxyPort", "8080");
// Next connection will be through proxy.
There are other proxy settings that you can set as well such as https, ftp, socks.
More resources:
http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html
No comments:
Post a Comment