License3j is a Java library that can be used to create and assert license files. This way Java programs can enforce the users to compensate their use of the software in the form of a payment. This is the usual way when closed source programs are distributed.
License management alone does not guarantee that the program will not be stolen, pirated or used in any illegal way. However license management may increase the difficulty to use the program illegal and therefore may drive users to become customers. There is another effect of license management, and that is legal. If there is sufficient license management illegal users have less probability to successfully claim their use was based on the lack or false of knowledge of license conditions.
License3j is an open source license manager that you can use free of charge for non-profit purposes. (only non-profit???) However...
what is the use of a license manager for nonprofit purposes? Nothing. And we did not want to make a software that is of no use. Therefore this license manager is free to use for profit purposes as well under the license terms covered by LGPL.
A license for license3j is a properties file that is signed electronically. You create the license file using a text editor or programmatically and encode it using license3j. When your program is used you load the license file, verify it using the Api of license3j and then get the property values and decide programmatically what features are available for your customer.
Not to reinvent the wheel we utilize the library from Bouncy Castle to perform the encryption and decryption and we use the format PGP to store the files. Therefore you have a wide range of tools readily available.
You can create and encode your licenses totally programmatically, or create the license manual and encode it using license3j or encode it using GPG. It is your choice.
To manage the key rings you have to use some PGP compatible program, like GPG. We did not develop the key management. However we provided a little document to help your first steps to create your licenses.
When the program is loaded you should load the encoded license file programmatically (you can not use GPG for this purpose, lol :-)
License3j can use external key ring file that is installed along with the Java file or a key ring file installed into the JAR file (as a resource).
It would be easy to fake a license replacing the key ring file containing the public keys, therefore license3j calculates the SHA512 fingerprint of the key ring file and provides you an api, where you can check this against a byte array you hard-wire into your code.
License3j also provides easy way to get this byte array in Java syntax.
In case you have more than one signing key for licenses you can also check which key was used to sign the license. You may limit the function of your program based on the signing key. For example you will not accept a commercial license that was signed by a demo license key.