title: Java + java.net.UnknownHostException
body: <p>I have tried adding proxy, nonProxyHost etc. in Eclipse but not able to pass through this error. I also read lot of pages around <code>java.net.UnknownHostException</code> but no luck. Below is the snippet and exception.</p>
  
  <pre><code>URL url = new URL("https://xyz.com/Something");
  URLConnection connection = url.openConnection();
  HttpURLConnection httpConn = (HttpURLConnection)connection;
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  OutputStream out = httpConn.getOutputStream(); //Fails with
  //Exception in thread "main" java.net.UnknownHostException: xyz.com
  </code></pre>
  
  <p>Full stack trace:</p>
  
  <pre><code>Exception in thread "main" java.net.UnknownHostException: xyz.com
      at java.net.PlainSocketImpl.connect(Unknown Source)
      at java.net.SocksSocketImpl.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
      at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(Unknown Source)
      at sun.net.NetworkClient.doConnect(Unknown Source)
      at sun.net.www.http.HttpClient.openServer(Unknown Source)
      at sun.net.www.http.HttpClient.openServer(Unknown Source)
      at sun.net.www.protocol.https.HttpsClient.&lt;init&gt;(Unknown Source)
      at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
      at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
  </code></pre>
  
  <p>I have tried setting below proxies through code:</p>
  
  <pre><code>System.setProperty("useDefaultWebProxy", "true");
  System.setProperty("https.proxyHost", "my_proxy_server");
  System.setProperty("https.proxyPort", "8080");
  System.setProperty("https.nonProxyHosts", "xyz.com");
  </code></pre>
  
  <p>Also, in Eclipse I have set proxy and proxy bypass in <code>Window -&gt; Preferences -&gt; General -&gt; Network Connection</code></p>