Note that there are some explanatory texts on larger screens.

plurals
  1. PONetworkInterface doesn't return all mac addresses
    primarykey
    data
    text
    <p>In part of our code i am trying to bind a mac address with our license file and i am facing an issue that my code for figuring out all the mac addresses of the machine is not returning all the physical mac addresses. Here is the code to get all the mac addresses</p> <pre><code>public static Collection&lt;String&gt; getAllLocalMacAddresses() throws IOException { final Enumeration&lt;NetworkInterface&gt; inetAddresses = NetworkInterface.getNetworkInterfaces(); final Collection&lt;String&gt; addresses = new LinkedList&lt;String&gt;(); while(inetAddresses.hasMoreElements()){ final byte[] macBytes = inetAddresses.nextElement().getHardwareAddress(); if(macBytes == null) continue; addresses.add(getMacAddress(macBytes)); } return addresses; } static String getMacAddress(byte[] macBytes){ final StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i &lt; macBytes.length; i++){ strBuilder.append(String.format("%02X%s", macBytes[i], (i &lt; macBytes.length - 1) ? ":" : "")); } return strBuilder.toString().toUpperCase(); } </code></pre> <p>Here is the result that i get from this method</p> <pre><code>[, 00:00:00:00:00:00:00:E0, 00:26:B9:30:6D:CB, 00:26:B9:30:6D:CB, 00:00:00:00:00:00:00:E0, 00:26:B9:30:6D:CB, 02:26:B9:30:6D:C1, 00:26:B9:30:6D:CB, 00:00:00:00:00:00:00:E0] </code></pre> <p>The output from "ipconfig /all" shows me these physical addresses (i could paste the out put for this command if required)</p> <pre><code>00-26-B9-30-6D-C3 02-26-B9-30-6D-C1 00-26-B9-30-6D-C5 00-26-B9-30-6D-C9 00-26-B9-30-6D-CB 00-00-00-00-00-00-00-E0 </code></pre> <p>Now if you see the java code did not return the address "00-26-B9-30-6D-C3" and also printed the address "00:26:B9:30:6D:CB" thrice. Any idea why this would be happening and how can i fix it. </p> <p>Any help will be deeply appreciated :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload