Check Local Host IP Address in Java Programming
Here, you shall learn How to Check Local Host IP Address in Java Programming that you’re currently logged in. Read below to know what is an IP Address. This Java Program is an IP Address Tracker Program wherein you can get the IP Address of your Local Host System by executing this IP Address Java Program.
What is an IP Address?
IP stands for Internet Protocol Address. It is a 32-Bit Address String and is also commonly known as IPv4 (Internet Protocol Version 4).
IP Address is a Numerical Tag associated with every Electronic Device such as Printer, Laptop, Desktop, Mobiles, etc that helps to identify every single device connected to a Network. It is primarily used for Communication with different devices connected onto the same Network.
Local Host is the Host Name of your System. Almost everytime, the Local Host Address is 127.0.0.1 which is the Ipv4 Loopback Address.
Also Read: Java Program To Check Public IP Address
How Does This Program Works?
InetAddress Class provides the facility to Check IP Address in Java Programming. It has a pre-defined method getLocalHost() that helps to get the Local Host IP Address. Local Host IP Address is 127.0.0.1 which is also known as Loopback Address.
Check Local Host IP Address in Java Programming Language
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import java.net.InetAddress; class SystemIPAddress { public static void main(String args[]) throws Exception { try { System.out.println("nYour System IP Address: t"); System.out.println(InetAddress.getLocalHost()); //It gives you the Local Host Address System.out.println("n"); } catch(Exception e) { System.out.println("Could Not Executen"); } } } |
Also Read: Java Code To Find Perfect Numbers
Output

To know more about IP Addresses, Refer WikiPedia. You can also check your IP Address on WhatIsMyIPAddress when you’re Connected to the Internet. We hope that you got a basic information about How To Check Local Host IP Address in Java Programming Language.