title: Getting interface NAME from java
body: <p>My OS is CentOS 6. In my /etc/sysconfig/network-scripts/ifcfg-eth0 file, I have specified the network interface <code>"NAME"</code> to <code>"foo"</code> (let's suppose). </p>
  
  <p><code>NAME=foo</code></p>
  
  <p>I want to be able to get that interface  <code>"NAME"</code> from java. I tried the following, without a result:</p>
  
  <pre><code>
       for (Enumeration nis = NetworkInterface.getNetworkInterfaces(); nis.hasMoreElements();) {
           NetworkInterface ni = nis.nextElement();
       System.out.println(ni.getDisplayName() + " " + ni.getName());
       }
  </code>
  </pre>
  
  <p>It displays the same thing:</p>
  
  <p><code>eth0 eth0</code></p>
  
  <p>Can anybody tell me if it is possible to get the value of <code>NAME</code>, property of a network interface, in java?</p>
  
  <p>Thanks.</p>
  
  <p>NOTE: When specify <code>NAME=foo</code>, then the name of that interface in the network panel placed on the up right corner of the screen is <code>foo</code>.</p>