code: private static byte[] macAddress() {
          try {
              Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
              byte[] mac = null;
  
              while (interfaces.hasMoreElements() && (mac == null || mac.length != 6)) {
                  NetworkInterface netInterface = interfaces.nextElement();
                  if (netInterface.isLoopback() || netInterface.isVirtual())
                      continue;
                  mac = netInterface.getHardwareAddress();
              }
  
              // if the machine is not connected to a network it has no active MAC address
              if (mac == null)
                  mac = new byte[] {0, 0, 0, 0, 0, 0};
  
              return mac;
          } catch (Exception e) {
              throw new RuntimeException("Could not get MAC address");
          }
      }
docs: Get the active MAC address on the current machine as a byte array. This is called when generating a new UUID.
  Note that a machine can have multiple or no active MAC addresses. This method works by iterating through the list
  of network interfaces, ignoring the loopback interface and any virtual interfaces (which often have made-up
  addresses), and returning the first one we find. If no valid addresses are found, then a byte array of the same
  length with all zeros is returned.
  @return 6-byte array for first active MAC address, or 6-byte zeroed array if no interfaces are active.