• Post Reply Bookmark Topic Watch Topic
  • New Topic

ip address ?  RSS feed

 
Vishakha Ahuja
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I determine the ip address of my home pc ?
 
Matt Siegel
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use java.net.InetAddress:

API: http://java.sun.com/j2se/1.3/docs/api/java/net/InetAddress.html
HTH!
Matt
 
Hemant KS Sengar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Try at MSDOS command prompt:
ipconfig
(if you just want to know about your PC's address)
or if it is in some java program try
InetAddress ad = InetAddress.getByName("localhost");
Hemant
[This message has been edited by Hemant KS Sengar (edited April 28, 2001).]
 
Shiraz Bhagwagar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Use this simple code.
import java.net.*;
class whoami{
public static void main(String args[]) throws Exception{
InetAddress a = InetAddress.getByName(null);
System.out.println(a);
}
}

The InetAddress .getByName with a paramater of null helps determine the local IP address.
 
Vishakha Ahuja
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou very much.
Regards,
Vishakha.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!