I am using windows 10 and I would like to plug a device on my computer (which created a new network interface with the name "Ethernet 12" and description "foobar") and be able to set the IP address of this interface using Java. Using this link: Change Computer IP address using JAVA, I am able to configure the IP address of the interface. The issue I have is that I am not able, in java, to retrieve the name of the interface created by the device. From the documentation I found, I did the following:
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while(networkInterfaces.hasMoreElements())
{
NetworkInterface networkInterface = networkInterfaces.nextElement();
if (networkInterface.isUp())
System.out.println("Display name: " + networkInterface.getDisplayName() + "\nName: " + networkInterface.getName() + "\nAddress: " + networkInterface.getInterfaceAddresses().get(0));
}
and got the following result:
Display name: foobar
Name: eth15
Address 111.116.15.4
I expected the name to be "Ethernet 12" and not "eth15", which doesn't seem to make any sense. I noticed the same for all my other interface (wifi, ethernet, etc...). Since I need the real name of my interface (Ethernet 12) to configure the IP address with netsh (and not a random one like "eth15"), I am stuck...
Is there a reason why I am getting "eth15" as the name of my interface ?
Thank you