Java Programming
Local Machine IP
Java programming example for get local machine IP address
By Geekboots
10/26/2021
0 views
local-machine-ip.javaJava
/* Get Local IP and Hostname */
import java.io.*;
import java.net.InetAddress;
public class getIP {
public static void main(String[] argv) throws Exception {
InetAddress addr = InetAddress.getLocalHost();
/* Get IP Address */
System.out.println("IP Address: "+addr.getHostAddress());
/* Get hostname */
System.out.println("Hostname: "+addr.getHostName());
}
}
/* Output */
IP Address: 127.0.1.1
Hostname: localhost
Java TutorialGet IPLocal IP Address