title: How can I detect the ethernet cable is connected with Java on Windows
body: <p>I need to know how to detect if the ethernet cable is plugged or unplugged using Java, I use <code>NetworkInterface</code> to check the interfaces, but I need to do an alert when the cable is unplugged and plugged again.</p>
  
  <pre><code>ArrayList&lt;NetworkInterface&gt; interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
  
      for (NetworkInterface info : interfaces){
          if(info.isUp()){
              System.out.println(info.getName());
          }
      }
  </code></pre>