Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a UUID or GUID in Java 1.4

Tags:

java

uuid

I need to create a UUID or GUID in java 1.4. I get a classnotfound exception when i use: java.util.UUID.

There are similar questions here linked below, but none answer with a generator for Java 1.4:

  • Likelihood of collision using most significant bits of a UUID in Java
  • Create a GUID in Java

I have also found a few classes online:

  • http://johannburkard.de/software/uuid/
  • http://jackrabbit.apache.org/api/1.4/org/apache/jackrabbit/uuid/UUID.html

What would you suggest I use to create a UUID or GUID in java 1.4?

like image 886
rabs Avatar asked Jul 27 '11 01:07

rabs


People also ask

How is Java UUID generated?

The randomUUID() method randomly generate the UUID. Whenever we run the program, it generates a new UUID. The signature of the method is: public static UUID randomUUID()

Does Java have a GUID?

GUIDs are used in enterprise software development in C#, Java, and C++ as database keys, component identifiers, or just about anywhere else a truly unique identifier is required. GUIDs are also used to identify all interfaces and objects in COM programming.


1 Answers

I suppose there is no chance convincing the client to get off an unsupported version of Java? Which if the answer is no then your only recourse is to use/modify one of the open source implementations from the web. You mentioned two of them in your question, another one you might want to look at is JUG.

And oh yea, your reference to java.util.UUID failed because it's only available in Java 5 and up.

Good luck!

like image 74
Perception Avatar answered Oct 05 '22 02:10

Perception