File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Class Cast Exception in HttpURLConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Class Cast Exception in HttpURLConnection" Watch "Class Cast Exception in HttpURLConnection" New topic

Class Cast Exception in HttpURLConnection

Rahul Juneja
Ranch Hand

Joined: Aug 03, 2002
Posts: 425

I am executing this line this Line works fine on Windows platform and when we move it to AIX Machine this throws a Class Cast Exception.

The URL We are passing is :

mind it it is "Https" Secured URL.

My Question is How is this Code working fine on Windows machine and if It works Why not on IBM - AIX Machine.

Any Comments or Suggestions Appreciated.

Rahul Juneja

Rahul Juneja
ThoughtClicks -
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

You are using different virtual machines, probably from different vendors (the windows VM from Sun and the AIX VM from IBM). This line:

breaks your contract with the API because you are claiming to know something about the implementation of the VM which obviously does not hold between platforms. The API states that openConnection returns an instance of URLConnection. You could test connection with the instanceof operator, but you'd still need to provide some processing for the platforms where connection is not an instance of HttpURLConnection.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Class Cast Exception in HttpURLConnection
It's not a secret anymore!