How to get your server IP address using Java

In this post we will show how to get your server IP address using Java.

How to get server IP address

The example below shows how to get the host server IP address.

The getLocalHost() method will return information about the host machine, calling getHostAddress() will give you the IP address. Running the above code produces the following output.

Output

In conclusion I hope you found this post of some use, and helps you solve you development issues.

Similar posts

  1. Java 8 reduce operation
  2. Convert InputStream to File
  3. Java 8 How to sort a Map

References

  1. Java InetAddress API documentation
  2. Getting the IP address of the current machine using Java

 

Leave a Reply

Your email address will not be published. Required fields are marked *