How to find IP address of local host from Java program
Java networking API provides method to find IP address of localhost from Java program by using java.net. InetAddress class. It’s rare when you need IP address for localhost in Java program. Mostly I used Unix command to find IP address of localhost. For all practical purpose where program doesn’t need IP address but you need to troubleshoot any networking issues, Use DOS or windows command or Use Linux commands. Recently one of my friend faced this question in a core Java interview, where they are expecting Java developer with some socket programming experience, But until you know or you have done it before its hard to answer this fact based question, which motivates me to write this post. In this Java tutorial we will see How to find IP address of localhost from Java program. By the way it’s also good to remember list of Unix networking commands to troubleshoot any networking issues related to Java application in Unix environment.