Sounds like a license key. I'm sure someone has written a library in Java for that, you only need to look for it and integrate it into your program.
Likely, it would need to phone home (via the web) to make sure the license key hasn't been used already. Or you could use an authentication scheme (username/password) to use on the web and for any web-based actions.