Proxy setting in java

3 properties can set in http,https and ftp proxy handler

Http proxy in java

1. http.proxyHost: the host name of the proxy server
2. http.proxyPort: the port number, the default value being 80.
3. http.nonProxyHosts:a list of hosts that should be reached directly, bypassing the proxy.

Add http proxy when run main class

1. $ java -Dhttp.proxyHost=webcache.example.com GetURL
2. $ java -Dhttp.proxyHost=webcache.example.com -Dhttp.proxyPort=8080 -Dhttp.nonProxyHosts=”localhost|host.example.com” GetURL

Add https proxy when run main class
1. $ java -Dhttps.proxyHost=webcache.example.com GetURL
2. $ java -Dhttps.proxyHost=webcache.example.com -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts=”localhost|host.example.com” GetURL

Add http proxy in java code

//Set the http proxy to webcache.example.com:808 0
System.setProperty("http.proxyHost", "webcache.example.com");
System.setProperty("http.proxyPort", "8080");
System.setProperty("http.nonProxyHosts", "localhost|host.example.com");

Remove proxy in java code
 System.setProperty("http.proxyHost", "webcache.example.com");

Add https proxy in java code

System.setProperty("https.proxyHost", "webcache.example.com");
System.setProperty("https.proxyPort", "8080");
System.setProperty("http.nonProxyHosts", "localhost|host.example.com");

Add https proxy in java code

3 properties can set in http proxy handler
    ftp.proxHost
    ftp.proxyPort
    ftp.nonProxyHosts
$ java -Dhttp.proxyHost=webcache.example.com -Dhttp.proxyPort=8080 -Dftp.proxyHost=webcache.example.com -Dftp.proxyPort=8080 GetURL


Comments

Popular posts from this blog

Using logstash to import csv json files into elasticsearch

Kibana 4 Installation and Run as a service in ubuntu