Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Casting problem

 
Isaac Ferguson
Ranch Hand
Posts: 839
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the code




Then import is:

import sun.net.www.protocol.http.HttpURLConnection;


and the error ;



Any idea?

Many Thanks, Isaac
 
Alexei Kaigorodov
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try "HttpsURLConnection rc" instead of HttpURLConnection .
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angus Ferguson wrote:import sun.net.www.protocol.http.HttpURLConnection;


Why that class? Just use the class from the standard API:

 
Isaac Ferguson
Ranch Hand
Posts: 839
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved. Many thanks
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15274
38
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angus Ferguson wrote:Then import is:

import sun.net.www.protocol.http.HttpURLConnection;

You should not be using classes in sun.* packages directly.

Explanation from Oracle: Why Developers Should Not Write Programs That Call 'sun' Packages
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic