
strong text

Java get system IP Address:
import java.net.*;
import java.io.*;
public class GetIPAddress {
public static void main(String [] args) {
try {
InetAddress thisIp =InetAddress.getLocalHost();
System.out.println("IP:"+thisIp.getHostAddress());
}
catch(Exception e) {
e.printStackTrace();
}
}
}

Java get Mac Address:
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
public class MacAdd {
public static void main(String[] args) {
try {
InetAddress add = InetAddress.getByName("192.168.20.53");
NetworkInterface ni1 = NetworkInterface.getByInetAddress(add);
if (ni != null) {
byte[] mac1 = ni1.getHardwareAddress();
if (mac1 != null) {
for (int k = 0; k < mac.length; k++) {
System.out.format("%02X%s", mac[k], (i < mac.length - 1) ? "-" : "");
}
} else {
System.out.println("Address doesn't exist ");
}
} else {
System.out.println("address is not found.");
}
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (SocketException e) {
e.printStackTrace();
}
}
}