tags:

views:

304

answers:

4

Possible Duplicate:
Generate UUID in Java

What are some of the best ways to create a GUID in Java?

+6  A: 

Have a look at the UUID class. For example:

Mark Byers
+2  A: 

java.util.UUID.randomUUID();

Kaleb Brasee
+3  A: 

This stackoverflow question discusses and link the topic in depth.

Daniel Ribeiro
I'm still getting used to forum protocol. How relevant is it that anyone who doesn't know that Java refers to GUIDs as UUIDs would have a lot of trouble finding that question and likely post again if this one is closed out? (The question refers to UUIDs and is only tagged with UUID)
DutrowLLC
Not sure I understand what you mean, but there is a closing vote for duplicate questions on StackOverflow. However, it requires a lot of reputation for voting, and I usually find its usage should be taken with a grain of salt. In the end, having more of the same question, even closed ones, is more benefical than having it answered only once.
Daniel Ribeiro
+3  A: 

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.

Stephen C