Question: Can somebody suggest any approach to generate unique Id preferably integer for Java classes .I need to have each of my Java classes to have some kind of a unique Id which would be written via a serialization strategy to be used to get back the same class in a distributed set up .

Answer: 
Take a look at the [UUID](https://docs.oracle.com/javase/1.5.0/docs/api/java/util/UUID.html#randomUUID%28%29) class. It has [toString()](https://docs.oracle.com/javase/1.5.0/docs/api/java/util/UUID.html#toString%28%29) function. You could take the hash of that value.
While not an integer, another way is to use SecureRandom:

```
new BigInteger(130, new SecureRandom()).toString(32)

```

returns a String that looks something like "61iook8njttgnmp06aku56gmtc"

Note that if at all possible it would be better to create a single SecureRandom and reuse it when generating your unique id.

**Edit**: sorry, can't comment yet but I see that you added a comment to the UUID answer - also an excellent way to solve the original problem you stated. However, now you want a "unique key" for your object. You really need to come up with a correct hashCode() method for your object. You need to answer what separates one version of your object from the other - a string perhaps that you could call hashCode() on?