[Java] Enable Proxy Support

Discussion in 'Code Snippets and Tutorials' started by Zer0, Dec 26, 2008.

  1. Zer0

    Zer0 Level IV

    Joined:
    Mar 2, 2008
    Messages:
    3,037
    Likes Received:
    180
    Location:
    Home sweet home
    This little snippet is to show you how to enable proxy support in Java :)
    Simple version
    Code (Text):
    1. System.getProperties().put( "proxySet", "true" );
    2. System.getProperties().put( "proxyHost", "ProxyIP" );
    3. System.getProperties().put( "proxyPort", "ProxyPort" );
    Slightly condensed version
    Code (Text):
    1. Properties p  = System.getProperties();
    2. p.put( "proxySet", "true" );
    3. p.put( "proxyHost", "ProxyIP" );
    4. p.put( "proxyPort", "ProxyPort" );
    To disable proxies
    Code (Text):
    1. System.getProperties().put( "proxySet", "false" );
    Not difficult eh? :tehe:
     
    tharoux likes this.
  2. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    Nice !!!
    If only I could have the time to get back to java :|