This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Casting problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Casting problem" Watch "Casting problem" New topic
Author

Casting problem

Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 377
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: 18570
    
    8

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

Joined: Jun 22, 2012
Posts: 377
Solved. Many thanks
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14193
    
  20

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 8 API documentation
 
GeeCON Prague 2014
 
subject: Casting problem