Simple piece of testing code:
public class Runner {
public static void main(String[] args) throws SocketException {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
System.out.println(networkInterfaces.nextElement().getName());
}
}
}
And the output:
docker0
enp3s0
lo
Output of ifconfig
:
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
<truncated>
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
<truncated>
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
<truncated>
wlp0s20u7: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
<truncated>
From my code, the interface wlp0s20u7
does not show up. This does happen though when I am not connected to any wireless network though. On connection, it does show up for wlp0s20u7
. Is there a way to get the NetworkInterface
object without a wireless connection?