import java.net.InetAddress;Output:
import java.net.UnknownHostException;
public class Clientaddress {
public static void main(String[] args) {
String hostname;
String addressIPLocale;
try{
InetAddress inetadr = InetAddress.getLocalHost();
//machinename
hostname = (String) inetadr.getHostName();
System.out.println("Machine Name = "+HostName);
//ip address on the network
IPLocale address = (String) inetadr.getHostAddress();
System.out.println("Local IP address = "+IPlOcale)
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
}
Machine Name = VAIO-VAIOReferences:
Local IP Address = 192.168.1.101
Please disable your ad blocker and refresh the window to use this website.