# License4J Licensing Example Application

This application demonstrates trial license usage and validation. It stores license information in user home directory with sample-app-license-file.lic". "License" menu item in Help menu has required buttons to request a trial, change product key, validate and activate a test license.

The easiest trial license implementation in License4J is to use single trial license key and perform activations with this single license key. Therefore you can generate a single license key and hard-code in your software product. When a user first run software, he/she can request a trial usage with a button click. Then runtime library auto-activates hard-coded trial license key on server, and trial period starts. After trial period ends, if user uninstall/re-install software and tries to request another trial license, he/she will get already activated and expired trial activation.
As a software publisher you can monitor trial license activations by just right clicking on trial license in License Manager and running "Manage Activations" menu item; you will see all trial activations with expiration dates.

## To generate trial license key:

- Start license generation wizard.
- On step 3, select basic license key
- On step 4, define quantity as 999999
- On step 5, enable activation
- On step 5, select activation period as 0 (zero)
- On step 5, select activation return as license text
- On step 5, select "set activated license text generation ..." checkbox. So trial period will begin when user first activated the license
- On step 5, select hardware ID(s) you want to use
- On step 6, set validity period. Like 30 days valid trial license
- On step 7, define a custom signed feature to identify this license as trial (like trial=yes)
- On step 8, preferably enable date/time check

## Some Source Files

"MyProductLicense.java" has all settings and validation methods defined. It is used to make this demonstration application simple. In a real application, you should validate licenses in a few different parts of your application.

"MyProductLicenseJDialog.java" is a simple licensing window to modify license and display information.

## TODO List

To test your licenses with this application search for word TODO in source file "MyProductLicense.java" and replace with your product information.

- Change publicKey variable with your public key in MyProductLicense.java file.
- Replace product id, edition and version with your settings in MyProductLicense.java file
- To use your own Auto License Generation and Activation Server or License Activation and Validation Server user your server address in autoActivate method in MyProductLicense.java file.

## Example Licenses

- QJ4GK-96PF7-M6CSA-AWGUE-TTQSA: This is a sample trial license key with 90 days validity period defined.
- AH2RN-26GDM-92PUN-5JWSU-Q362H: This is a 1 year valid normal license key and requires activation, to test example when a customer purchased product.
- PTBSZ-C4IJ2-X4WPB-3H4FQ-PM33K: This is a 2 year valid normal license key and requires activation, to test example when a customer purchased product.

## Note

License validation/activation can be made in many different ways. Use of threads or SwingWorker may change in your product. This is just an example application to help start license validation.