This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Class Cast Exception in HttpURLConnection

 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Thanks,
Rahul Juneja
rahulj2k3@yahoo.com
 
Bartender
Posts: 9559
12
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!