title: How to get proxy settings from system settings in Java
body: <p>I'm  looking form way how to get system proxy information in Java under Windows, but I've found just one way. But it does not work for me.</p>
  
  <pre><code>public static void main(String[] args) throws Throwable {
    System.setProperty("java.net.useSystemProxies", "true");
    System.out.println("detecting proxies");
    List&lt;Proxy&gt; pl = ProxySelector.getDefault().select(new URI("http://ihned.cz/"));
    for (Proxy p : pl)
      System.out.println(p);
    Proxy p = null;
    if (pl.size() &gt; 0) //uses first one
      p = pl.get(0);
    System.out.println(p.address());
    System.out.println("Done");
  }
  </code></pre>
  
  <p>When I run the program, I get:</p>
  
  <pre class="lang-none prettyprint-override"><code>detecting proxies
  DIRECT
  null
  Done
  </code></pre>
  
  <p>Java means, that I'm situated directly on internet. But it's wrong. I'm behind proxy. I'm unable to get the solution for my computer.</p>