Possible Duplicate:
Generate UUID in Java
What are some of the best ways to create a GUID in Java?
Possible Duplicate:
Generate UUID in Java
What are some of the best ways to create a GUID in Java?
Have a look at the UUID class. For example:
This stackoverflow question discusses and link the topic in depth.
It depends what kind of UUID you want.
The standard Java UUID class generates type 3 and 4 UUIDs.
The Java UUID Generator (JUG) implementation purports to support "all 3 'official' types of UUID as defined by RFC-4122" ... though the RFC actually defines 4 types and mentions a 5th type.
For more information on UUID types and variants, there is a good summary in Wikipedia, and the gory details are in the RFCs and other specifications.