Java tutorial
//package com.java2s; import java.nio.ByteBuffer; import java.util.UUID; public class Main { public static byte[] randomUUID() { UUID uuid = UUID.randomUUID(); long hi = uuid.getMostSignificantBits(); long lo = uuid.getLeastSignificantBits(); return ByteBuffer.allocate(16).putLong(hi).putLong(lo).array(); } }