private static void setProxy(String proxyHostName,int proxyport){
    proxy=new Proxy(Proxy.Type.HTTP,new InetSocketAddress(proxyHostName,proxyport));
}
private static void setProxy(String proxyHostName,int proxyport,String username,String password){
    setProxy(proxyHostName,proxyport);
    if (username!=null && password!=null) {
        Authenticator authenticator = new Authenticator() {
            public PasswordAuthentication getPasswordAuthentication() {
                return (new PasswordAuthentication(username, password.toCharArray()));
            }
        };
        Authenticator.setDefault(authenticator);
    }
}
this is code for proxy setting.I don't know why it's throwing this error.
exception:
java.io.IOException: Unable to tunnel through proxy. Proxy returns ""HTTP/1.1 407 Proxy Authentication Required"" at sun.net.http://www.protocol.http.httpurlconnection.dotunneling%28httpurlconnection.java:2142/) at sun.net.http://www.protocol.https.abstractdelegatehttpsurlconnection.connect%28abstractdelegatehttpsurlconnection.java:183/) at sun.net.http://www.protocol.https.httpsurlconnectionimpl.connect%28httpsurlconnectionimpl.java:162/) ..