Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting Exception in main method..

 
Siddhesh Desai
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.net.*;
import java.util.*;
import java.io.*;

class InetAddressTest
{
public static void main(String args[])
throws UnknownHostException
{
InetAddress Address = InetAddress.getLocalHost();
System.out.println(Address);
//Address = InetAddress.getByName("www.yahoo.com");
//System.out.println(Address);
InetAddress SW[] = InetAddress.getAllByName("www.nba.com");
for(int i=0; i<SW.length;i++)
System.out.println(SW[i]);
}
}
Follawing Error is getting

Exception in thread "main" java.net.UnknownHostException: www.nba.com: www.nba.c
om
at java.net.InetAddress.getAllByName0(InetAddress.java:948)
at java.net.InetAddress.getAllByName0(InetAddress.java:918)
at java.net.InetAddress.getAllByName(InetAddress.java:912)
at InetAddressTest.main(InetAddressTest.java:14)
-------------------------------------------------------------------
Please Help
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe it is because u r using some proxies to connect to the outside internet. Could you try with the name of a machine in ur LAN? u will see that it is working...

I've just tried with your code and it's working with the name of the machine in my LAN....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic