Press enter to see results or esc to cancel.


sun.net.www.protocol.http.HttpURLConnection cannot be cast to javax.net.ssl.HttpsURLConnection

  1. Error
    java.lang.ClassCastException: sun.net.www.protocol.http.HttpURLConnection cannot be cast to javax.net.ssl.HttpsURLConnection
    	at com.chillyfacts.com.Send_HTTP_Request.call_me(Send_HTTP_Request.java:21)
    	at com.chillyfacts.com.Send_HTTP_Request.main(Send_HTTP_Request.java:13)
    
  2. You might be using
    URL obj = new URL(url);
    HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
    

    Solution,Convert it to http protocol

    URL obj = new URL(url);
    HttpURLConnection con = (HttpURLConnection) obj.openConnection();
    

    See the Example shown in this link,
    http://chillyfacts.com/java-send-http-getpost-request-and-read-json-response/


Tags

Comments

Leave a Comment