• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

java.net.UnknownHostException

 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been running the PickAWinners program from the console or from netBeans without any trouble. I decided to try running it from Eclipse for this week's giveaway and it won't work. It keeps giving me a java.net.UnknownHostException: saloon.javaranch.com. Obviously saloon.javaranch.com is not an unknown host. I ended up running the winners from NetBeans without any trouble. Is there some configuration you have to do to get Eclipse to get it to read over the internet? Or am I missing something very obvious?
Thanks for any help.
Full exception:
Reading main forum page(s)...
https://coderanch.com/forums/f-50/JSP&start_point=0
java.net.UnknownHostException: saloon.javaranch.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.javaranch.postselector.ParsedWebPage.<init>(ParsedWebPage.java:116)
at com.javaranch.postselector.Forum.parseForumPage(Forum.java:63)
at com.javaranch.postselector.Forum.parseCandidateTopics(Forum.java:158)
at com.javaranch.postselector.Forum.<init>(Forum.java:50)
at com.javaranch.postselector.PostSelector.main(PostSelector.java:42)
Exception in thread "main"
 
Dastardly Dan the Author
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The short answer is that it shouldn't matter whether you launch from Eclipse or anywhere else. Obviously in your case you've found otherwise, so the goal is to discover what's different.
I really don't know but I'll venture a few guesses. Is it possible that Eclipse is running in the test environment and using its JRE (<inst_dir>\eclipse\jre), while NetBeans and the console are using another system JRE? I would expect it to work in either case, but it's a guess.
So what's the difference? I always start by looking at the configuration from Help > About > Configuration Details. It will show something like this:

You can set the test environment JRE under Window > Preferences > Java > Installed JREs. A final longshot that comes to mind is a difference in paths (e.g., to your hosts file). It may be different for a JRE invoked via the command line versus one launched by Eclipse. Like I said, I doubt that's the case... but can you get to it by IP address? Other sites?
One final hint: Launch your program under the Eclipse debugger (Run > Debug As > Java Application). Select the process in the stack frame, then Properties. It will display precisely what command line arguments were used to launch the executable, e.g.:

Here I just ran a simple "Hello" application. You can see that the debugger is hooking back to it locally (-Xrunjdwp:transport=dt_socket,suspend=y,address=localhost:12708 Hello). You can execute the same parameters from the command line and debug just the same as if you'd launched from Eclipse. This is documented and an example is included with our book (Chapter 4, "Remote Debugging" and Exercise 3).
-- Dan
[ August 02, 2003: Message edited by: Dan Kehn ]
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Proxy problem?
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it was a moment of stupidity on my part. I did say it might have been something obvious. My firewall didn't recognize Eclipse and was blocking it when it tried to access the net. One click and now it works.
Thanks, Dan. Your long post wasn't a complete waste as their was lots of good stuff in there!
 
Dan Kehn
Dastardly Dan the Author
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ohh-h, that would do it. I've been saved from that because my firewall puts up a warning if there is an access that doesn't fit a rule. Yours must be set up for a silent block. Anyway, glad to hear it was something simple.
-- Dan
 
There's a city wid manhunt for this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic