Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unknown host excpetion

Raja_236Feb 12 2013 — edited Feb 12 2013
Hi,

am getting below unknown exception while execution below code. Please suggest how to get rid of this exception.
mport java.io.InputStreamReader;
import java.net.URL;

class Mainclass3
{
	public static void main(String[] args) throws Exception 
	{
       System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");

	   URL url = new URL ("https://www.google.com/");
	   BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
	   String line;
	   while ((line = in.readLine()) != null)

	   {
		   System.out.println(line);
	   }
	   in.close();

	}
}
Exception details
Exception in thread "main" java.net.UnknownHostException: www.google.com
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
        at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.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.protocol.https.HttpsClient.<init>(Unknown Source)
        at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
        at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl.getInputStream(Unknown Source)
        at java.net.URL.openStream(Unknown Source)
        at Mainclass3.main(Mainclass3.java:12)
thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 12 2013
Added on Feb 12 2013
3 comments
381 views