3

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?

2

1 Answer 1

6
  1. 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.

  2. (a) None, except that you shouldn't use proxyHost/Port because they are obsolete. (b) The documentation doesn't say so.

  3. 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.

  4. This has been answered in @tostao's comment.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.