title: How to use Proxy password authentication on Java's Native HTTP Client
body: <p>I'm trying to use password authentication if a proxy requires it for Java's Native HTTP Client requests.</p>
  
  <p>I have tried a bunch of stuff, with the most common solution applied to my program being</p>
  
  <pre><code>String username = "username";
  String password = "password";
  
  Authenticator.setDefault( new Authenticator() {
              @Override
              protected PasswordAuthentication getPasswordAuthentication() {
                  return new PasswordAuthentication(username, password.toCharArray());
              }
          });
  </code></pre>
  
  <p>But after that I'm still getting error 407 when sending the request (which works fine on an IP Authenticated proxy). The proxy works just fine on a browser running it through a Chrome extension.</p>