I need to know how to detect if the ethernet cable is plugged or unplugged using Java, I use NetworkInterface to check the interfaces, but I need to do an alert when the cable is unplugged and plugged again.
ArrayList<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
    for (NetworkInterface info : interfaces){
        if(info.isUp()){
            System.out.println(info.getName());
        }
    }
				
                        
This is old thread, but may be useful for researchers. Modified according to response of J R.