This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Sockets and Internet Protocols and the fly likes How to get DNS name and IP Address with Java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply locked New topic
Author

How to get DNS name and IP Address with Java code

SP Nam
Ranch Hand

Joined: Oct 15, 2003
Posts: 41
How can I get my DNS servername and IPAddress, by just running a java program from command prompt, code help please
Vinod Chandana
Ranch Hand

Joined: Aug 26, 2003
Posts: 59
Try InetAddress.getLocalHost().getHostName() and InetAddress.getLocalHost().getHostAddress(). This will give u both name and the address of the localhost. Hope this helps. If not give me a message.
Vinod.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

I'm closing this thread, as it's a duplicate of this one, where the question has already been answered. Please post followups there.


[Jess in Action][AskingGoodQuestions]
 
 
subject: How to get DNS name and IP Address with Java code