Skip to Main Content

Java Programming

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!

Detecting my External IP Address?

807603Dec 10 2007 — edited Dec 10 2007
Hi,

I am writing an application which has to create an INI file for the user. The application then launches a separate application with the INI file as an argument. This INI file contains information, including the IP address of the current user.

My program is more or less a GUI to this rather cryptic console-based application. Typically, when you launch the console-based application, it prompts the user for the IP address. But the whole point of my GUI tool is to make the user experience that much easier.

So I do not want to have my users have to determine and enter their IP address manually, I'd rather be able to detect it.

After a lot of searching, the only solution I've found is to query http://www.whatismyip.org and take the response from that web page. But I am sure you can imagine my hesitation to rely on external resources for my product.

Is there any Java library or function to detect my external IP address? InetAddress.getLocalHost:().getHostAddress() returns the INTERNAL IP address assigned by your router...

Thanks!
-Josh
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 7 2008
Added on Dec 10 2007
3 comments
198 views