wood burning stoves*
The moose likes Beginning Java and the fly likes Getting Exception in main method.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Getting Exception in main method.." Watch "Getting Exception in main method.." New topic
Author

Getting Exception in main method..

Siddhesh Desai
Greenhorn

Joined: Jun 28, 2004
Posts: 9
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

Joined: Jun 08, 2002
Posts: 3178
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....


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting Exception in main method..