• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can i find out the ip address of the machine in Java

 
ying lam
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How can I find out the real ip address of the machine running my java program:

I tried this:
http://www.exampledepot.com/egs/java.net/Local.html

But it gives me 127.0.0.1, I need to know the real ip address of the machine that my Java program is running on.

Thank you.
 
Paul Clapham
Sheriff
Posts: 21871
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you didn't know that your machine can have more than one IP address. For example if you have an Ethernet cable connection and a wireless network connection, they have different IP addresses.

Anyway, there's a getAllByName(host) method in the InetAddress class that might help you.
 
John Melton
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!