Here is my ipconfig stat
Ethernet adapter Ethernet 3:
Connection-specific DNS Suffix . :
IPv6 Address. . . . . . . . . . . :
**IPv4 Address. . . . . . . . . . . :** -> This I want to retrieve.
Subnet Mask . . . . . . . . . . . :
Default Gateway . . . . . . . . . : ::
Ethernet adapter Ethernet:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Unknown adapter Local Area Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Local Area Connection* 1:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Local Area Connection* 3:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . :
IPv6 Address. . . . . . . . . . . :
Temporary IPv6 Address. . . . . . :
Temporary IPv6 Address. . . . . . :
Temporary IPv6 Address. . . . . . :
Temporary IPv6 Address. . . . . . :
Temporary IPv6 Address. . . . . . :
Temporary IPv6 Address. . . . . . :
Link-local IPv6 Address . . . . . :
IPv4 Address. . . . . . . . . . . :
Subnet Mask . . . . . . . . . . . :
Default Gateway . . . . . . . . . :
Ethernet adapter Bluetooth Network Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Ethernet adapter vEthernet (Default Switch):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . :
IPv4 Address. . . . . . . . . . . :
Subnet Mask . . . . . . . . . . . :
Default Gateway . . . . . . . . . :
Here is the code snippet I used
import java.net.InetAddress;
class IPAddressExample {
public static void main(String args[]) throws Exception {
InetAddress inetAddress = InetAddress.getLocalHost();
System.out.println("IP Address:- " + inetAddress.getHostAddress());
System.out.println("Host Name:- " + inetAddress.getHostName());
}
}
This gives me 127.0.0.1, but I need the local ip(the one which I have made bold). Tried many solutions that is there online, but all gave 127.0.0.1, instead of 10.xx.xxx.xxx
Any solution for this