dcsimg
UnknownHostException
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   akhil_chityal
Posted On:   Friday, September 3, 2004 11:07 PM

I am working with networking programming. In my program I want to get the information from yahoo.com, and i want to print the out put to the console. now my program is import java.net.*; import java.io.*; class URLReader2 { public static void main(String args[]) { try { URL yahoo = new URL("http://www.yahoo.com/"); DataInputStream dis; String inputLine; dis = new DataInputStream(yahoo.openStream()); while ((inputLine = dis.readLine()) != null) { System.out.println(inputLine); } dis.close(); } catch (MalformedURLException me) { S   More>>


I am working with networking programming.
In my program I want to get the information from yahoo.com, and i want to print the out put to the console.
now my program is


import java.net.*;

import java.io.*;


class URLReader2 {

public static void main(String args[]) {

try {

URL yahoo = new URL("http://www.yahoo.com/");

DataInputStream dis;

String inputLine;


dis = new DataInputStream(yahoo.openStream());

while ((inputLine = dis.readLine()) != null) {

System.out.println(inputLine);

}

dis.close();

} catch (MalformedURLException me) {

System.out.println("MalformedURLException: " + me);

} catch (IOException ioe) {

System.out.println("IOException: " + ioe);

}

}

}




But when i am running this program it is throwing an exception like


java.net.UnknownHostException: www.yahoo.com
at java.net.PlainSocketImpl.connect

(PlainSocketImpl.java:153)
at java.net.Socket.connect(Socket.java:426)
at java.net.Socket.connect(Socket.java:376)
at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:386)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:602)
at sun.net.www.http.HttpClient. (HttpClient.java:303)
at sun.net.www.http.HttpClient. (HttpClient.java:264)
at sun.net.www.http.HttpClient.New(HttpClient.java:336)
at sun.net.www.http.HttpClient.New(HttpClient.java:317)
at sun.net.www.http.HttpClient.New(HttpClient.java:312)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
ction.java:481)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
.java:472)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:574)
at URLConnectionReader.main(URLConnectionReader.java:30)

please any body help me to solve the problem
I worked with the following command also.

java -DproxySet=true -DproxyHost=proxyhost URLReader2
still i am getting the same error.
please any body help me

   <<Less

Re: UnknownHostException

Posted By:   Anonymous  
Posted On:   Friday, September 17, 2004 01:10 PM

Try adding in -DproxyPort as well ..
so , in essence, your command would be something like :

java -DproxySet=true -DproxyHost=nnn.nn.nn.nnn -DproxyPort=nn URLReader2


Good luck Akhil !
About | Sitemap | Contact