1

I am looking for a way to generate a Unique ID for a system such that, every time this ID is generated it should be same as long as on the system. (I am not sure if that's even possible) I am using Java to achieve this and should run on Windows and Unix (Linux) both

After spending sometime searching through various article if found some good solutions but each had its own limitations. Following 2 options were very close though.

  1. Using UUID package in Java: This gives out unique ids where in possible of collision is infinitesimal but I don't get same unique ID for a system.
  2. Using mac address of the system: I doubt that this would work well with Virtual Hosts.

Any suggestions folks?

Salman A. Kagzi
  • 3,833
  • 13
  • 45
  • 64

1 Answers1

0

Generate a UUID, and save either the 128-bits or their hex string representation to storage. Later read from storage to discover the value you previously wrote.

The bundled class java.util.UUID can generate either a version 3 or version 4 UUID. Other libraries can generate the other versions.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154