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!

How to get the real IP Address in Linux environment?

843790Oct 24 2006 — edited Oct 26 2006
Hi,

I have a computer which installs Red Hat Linux OS, I use the following code to get the IP for it :

String ip = InetAddress.getLocalHost().getHostAddress();

but the ip's value is 127.0.0.1, not the real IP 192.168.222.45, but the same code works well in Windows and Solaris, how to solve the problem ?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 23 2006
Added on Oct 24 2006
11 comments
183 views