Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

HTTP 407 - Proxy Authentication Required

843834Mar 8 2004 — edited May 28 2009
I can't get past our proxy server. Below is a test case that returns an HTTP 407 error ...

Exception in thread "main" java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.google.com/
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:691)
at java.net.URL.openStream(URL.java:955)
at URLReader.main(URLReader.java:12)

I got the settings from my browser (IE6.0), except for the "proxyType" which was suggested in another thread. I have also read (and applied) the javaworld tip #42, but still no go. Any thoughts?

import java.net.*;
import java.io.*;
import java.util.*;

public class URLReader {
    public static void main(String[] args) throws Exception {
        // Configure proxy ...
        System.setProperty("http.proxySet", "true");
        System.setProperty("http.proxyHost", "205.160.225.143");
        System.setProperty("http.proxyPort", "80");
        System.setProperty("http.proxyType", "4");

        // Open URL ...
        URL url = new URL("http://www.google.com/");
        BufferedReader in = new BufferedReader (
                              new InputStreamReader (
                                url.openStream ()
                              )
                            );

        // Read it ...
        String inputLine;
        while ((inputLine = in.readLine()) != null)
          System.out.println(inputLine);

        in.close();
    }
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 25 2009
Added on Mar 8 2004
11 comments
9,738 views