Skip to Main Content

Java APIs

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!

getHostName returns ip address !

843790Jul 21 2008 — edited Jul 22 2008
For some ip address getHostName returns ip address instead of resolving into domain name !

# ./java -version
java version "1.6.0_07"

-# ./java ipres 137.227.5.37
137.227.5.37

-# ./java ipres 137.229.13.237
rakof-ilo.alaska.edu

# nslookup 137.229.5.37
Server: 10.206.194.12
Address: 10.206.194.12#53

Non-authoritative answer:
37.5.229.137.in-addr.arpa name = rakof-ilo.alaska.edu.

Authoritative answers can be found from:



# nslookup 137.229.13.237
Server: 10.206.194.12
Address: 10.206.194.12#53

Non-authoritative answer:
237.13.229.137.in-addr.arpa name = rakof-ilo.alaska.edu.

Authoritative answers can be found from:

============code snippet==================
import java.net.*;
class ipres
{
public static void main(String[] args)
{
String hostName;
try {
InetAddress address;
address = InetAddress.getByName(args[0]);
hostName = address.getHostName();
System.out.println(hostName);
}
catch (Exception e)

{
System.out.println("Exception");
}

}
}
===========================================

Can any please explain me why it is happening ?

I appreciate your help very much!

Thanks,
Shaik Sulaiman

Edited by: sulaiman_sh on Jul 21, 2008 9:26 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 19 2008
Added on Jul 21 2008
2 comments
425 views