Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1036199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:39:53+00:00 2026-05-16T14:39:53+00:00

I try to establisch a HttpsURLConnection with: HttpsURLConnection conn = (HttpsURLConnection) new URL(url).openConnection() but

  • 0

I try to establisch a HttpsURLConnection with:

HttpsURLConnection conn = (HttpsURLConnection) new URL(url).openConnection()

but I get an Exception:

E/JavaBinder(  901): java.lang.ClassCastException: org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection

But I can’t find out, why. The same example is everywhere across the web.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:39:54+00:00Added an answer on May 16, 2026 at 2:39 pm

    The ClassCastException is telling you that the object being returned is not a HttpsUrlConnection. The cast you are doing is inherently unsafe, instead you should something like:

    URLConnection conn = new URL(url).openConnection();
    if (conn instanceof HttpsURLConnection) {
      // do stuff
    }
    else {
      // error?
    }
    

    As to the reason its not giving you an Https version, what url are you providing it with? My guess is you are giving it http:.. instead of https:…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I'm using following code to establish a url connection. But randomly I get
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
try: recursive_function() except RuntimeError e: # is this a max. recursion depth exceeded exception?
try { JSONArray jArray = new JSONArray(result); for(int i=0;i<jArray.length();i++) { JSONObject json_data = jArray.getJSONObject(i);
i try to connect to MySQL DB via a PHP5 class but i didn't
I'm new to java and Oracle connection I can't establish a connection from java/tomcat
I'll try asking this again but without typing mistakes.... I'm connecting using MySQLi and
i have created a new Facebook application and i used the following url as
I try to establish a build pipeline on Jenkins with a Play(2.0.2) project. As
I'm having a really difficult time debugging this problem. Whenever I try to establish

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.