I have a simple code for setting up a https connection to google and printing the response obtained.
import java.io.OutputStreamWriter;
import java.net.URL;
If you are behind the proxy and faced this Exception then, this solution will work for you.
public class SendCertReq {
public static void main(String[] args) throws Exception {
URL url = new URL("https://www.google.co.in/");
//Remember to Add proxy IP Address where 192.168.0.1 is my Proxy Address and Port is 8080.
// Change as per your proxy setting
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("192.168.0.1", 8080));
HttpsURLConnection conn = (HttpsURLConnection)url.openConnection(proxy);
conn.setRequestMethod("GET");
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.close();
System.out.println(conn.getResponseMessage());
}
}