File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes UID Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "UID" Watch "UID" New topic


shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
Can I use java.rmi.dgc.VMID to generate a unique number even if i deploy my application in different hosts and /or environments. I have a web application which will deployed in an app server. SO i need to make sure that the UID i generate is unique even if i change my app server or my machine. Or if there is any other solution, pls let me know.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32818

According to the Javadoc:

Create a new VMID. Each new VMID returned from this constructor is unique for all Java virtual machines under the following conditions: a) the conditions for uniqueness for objects of the class java.rmi.server.UID are satisfied, and b) an address can be obtained for this host that is unique and constant for the lifetime of this object.

The significant constraint for UID is that the clock will never be turned back on the server. Assuming that is a reasonable assumption, you should be ok.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: UID
It's not a secret anymore!