Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

java problem

  • 28-01-2005 7:29pm
    #1
    Registered Users, Registered Users 2 Posts: 3,548 ✭✭✭


    Im trying to write a simple program to connect to a website using URL objects. However, im constantly getting this UnknownHostException. Anything Ive read regarding this so far seems to talk about proxys, but I dont use one!

    Anyone know whats going on?

    Heres my simple code:

    import java.io.*;
    import java.net.*;

    class Tester
    {
    public static void main(String[] args)
    {
    try {
    URL yahoo = new URL("http://www.yahoo.com");
    URLConnection yc = yahoo.openConnection();

    BufferedReader in = new BufferedReader(
    new InputStreamReader(
    yc.getInputStream()));


    }catch (UnknownHostException e) { e.printStackTrace(); // new URL() failed

    } catch (MalformedURLException e) { e.printStackTrace(); // new URL() failed

    } catch (IOException e) { e.printStackTrace(); // openConnection() failed

    }
    System.out.println("Done");
    }
    }


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Compiling and running fine for me... Even wrote a loop into it to print the HTML to the console...


  • Registered Users, Registered Users 2 Posts: 3,548 ✭✭✭Draupnir


    just doesnt make sense, heres the error I get:

    E:\NationalAssistant>java Tester
    java.net.UnknownHostException: www.yahoo.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.New(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown
    Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Sour
    ce)
    at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
    urce)
    at Tester.main(Tester.java:12)
    Done


  • Registered Users, Registered Users 2 Posts: 240 ✭✭Manchegan


    Uh... try being connected to the Intarweb ;)


  • Registered Users, Registered Users 2 Posts: 2,243 ✭✭✭zoro


    I THINK you need "http://&quot; in front of it.


  • Registered Users, Registered Users 2 Posts: 261 ✭✭HaVoC


    might be the problem described here
    under the heading "A More Serious Issue"


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 3,548 ✭✭✭Draupnir


    yeah I was connected to the Internet and I also had http in front of it thanks Dan! Got the program running by using my laptop. I only get that eror on my desktop for whatever strange reason, even though im connecting both to the same router.


  • Registered Users, Registered Users 2 Posts: 2,243 ✭✭✭zoro


    How do you know me? :)


  • Registered Users, Registered Users 2 Posts: 3,548 ✭✭✭Draupnir


    Tis me, the former owner of RimLand, one half of the Redmond - Winders double act.


  • Registered Users, Registered Users 2 Posts: 2,243 ✭✭✭zoro


    Ah I see! Well - you can ask for help any time :)


Advertisement