It's not a secret anymore!
The moose likes Java in General and the fly likes Casting problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Casting problem" Watch "Casting problem" New topic
Author

Casting problem

Angus Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 240
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

Joined: Feb 24, 2008
Posts: 17
Try "HttpsURLConnection rc" instead of HttpURLConnection .
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

Angus Ferguson wrote:import sun.net.www.protocol.http.HttpURLConnection;


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

Angus Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 240
Solved. Many thanks
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12924
    
    3

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


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Casting problem
 
Similar Threads
No import javax.microedition.io.Connector; in Android?
get file path from url ?
Problem with HttpURLConnection
SSLHandshake Error while connection to remote server
Java with curl (http://curl.haxx.se/)