• Post Reply Bookmark Topic Watch Topic
  • New Topic

Opening URL Connection  RSS feed

 
Mark Mokris
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple standalone Java application that opens a URLConnection then reads it as a stream. This is just like reading a web page programmatically.

When I execute the app from the DOS command prompt with 'java', it executes fine. When I run it from the JBuilder IDE, it fails to "connect" and the contentLength return value is -1. Is this a security issue? Why does it work from the basic Java JRE, but not when run from within an IDE like JBuilder?
What it means is that I cannot debug the rest of the app using JBuilder's debugger I guess.
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I execute the app from the DOS command prompt with 'java', it executes fine. When I run it from the JBuilder IDE, it fails to "connect" and the contentLength return value is -1.
I had a similar problem. I bet that when you run it from the command prompt, your app runs under JDK 1.3, and when you run it from JBuilder, it uses JDK 1.4. See this thread for more information.
Eugene.
 
Mark Mokris
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eugene! WOW! You are right on!!!
I would never have guessed this, but where it works I am using jdk1.3 and where it doesn't work I am using jdk1.4. I actually don't need the contentLength, I was using it to tell me whether the connection was successful or not. I guess I will just go ahead and read the thing and not worry aout the content length.
MAN I OWE YOU A BEER! THANKS!
Thanks for sending me the private message on this too.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MAN I OWE YOU A BEER!
Offer him Vodka instead. And, by the way, he doesn't like shouting.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!