Reputation: 2313
Googled and find few links about proxy settings in Java, but few things make me a little confused
1) Do we really need to set the proxySet property or not?
System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "proxyHost", "proxy host" );
System.getProperties().put( "proxyPort", "8080" );
2) What's difference between setting http.proxyHost and proxyHost? basically, does it mean that the "proxyHost" one will be applied to all protocols including http, https, ftp, etc, whereas http.proxyHost only applies to http protocol?
System.getProperties().put( "proxyHost", "proxy host" );
or
System.getProperties().put( "http.proxyHost", "proxy host" );
3) Do we always need to do afterwards?
System.getProperties().put( "proxySet", "false" );
System.getProperties().put( "proxyHost", "" );
System.getProperties().put( "proxyPort", "" );
4) Where is the detailed and official documentation about doing proxy settings in Java?
Upvotes: 2
Views: 3899
Reputation: 311054
No. There is no such property as proxySet
. It was a feature of the long-defunct HotJava bean in 1997, and from there it has leaked into various 3rd-party books. There has never been such a property in the JDK, and I've looked at all of them since 1.1.2. For proof, set the other two and set proxySet
to false and see what happens. NB this question is indeed answered by the documentation, as proxySet
does not appear there.
(a) None, except that you shouldn't use proxyHost/Port
because they are obsolete. (b) The documentation doesn't say so.
See (1) for proxySet
. It would be more to the point to set the others to null rather than "" but I don't believe it has any effect: once the properties have been loaded they stick. If you need to control proxying dynamically you need to use java.net.Proxy.
This has been answered in @tostao's comment.
Upvotes: 6