Skip to Main Content

Java APIs

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!

ClassCastException while instantiate HttpsURLConnection

843790Jan 13 2009 — edited Jan 13 2009
When I try to instantiate an HttpsURLConnection from an URL instance called "Server,"
HttpsURLConnection conn =(HttpsURLConnection) server.openConnection();
I got the following exception:

java.lang.ClassCastException: sun.net.www.protocol.http.HttpURLConnection incompatible with javax.net.ssl.HttpsURLConnection

May I know if there is anyway to solve it? I have to use HttpsURLConnection.

Thank you!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 10 2009
Added on Jan 13 2009
4 comments
1,009 views