Link to home
Start Free TrialLog in
Avatar of dpalyca755
dpalyca755

asked on

retrieving local IP address

How do I get the IP address of the box I am running on in java code?
ASKER CERTIFIED SOLUTION
Avatar of mickay369
mickay369

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
InetAddress address = InetAddress.getLocalHost() ;
String ip = address.getHostAddress() ;

of course you need to handle UnknownHostException
Avatar of CEHJ
Do you really mean the 'local' address, i.e. the likely private address? Sometimes you need to know the address as seen by the outside world. If so, see
http://technojeeves.com/joomla/index.php/free/88-what-is-my-ip-java