Licensing

Overview

The evaluation mode of Aspose.BarCode for Java allows generating barcode images without restrictions. However, a watermark will be displayed on the resulting barcode image (words “Aspose”). The unlicensed version can be used to read barcodes of all supported types. Please note that only Code 39 can be decoded without limitations; as a result of reading barcodes corresponding to other types, 30% of decoded text will be masked with " * “. All other actions with barcodes using Aspose.BarCode for Java need setting a license. After purchasing a license, you will get access to the whole functionality of the library and the ability to perform barcode generation and reading without limitations and watermark placement.

How to Obtain License

If you want to try the full version of Aspose.BarCode for Java, you can try a temporary license that is valid for 30 days. Please read How to get a Temporary License? for more information. To use the library without limitations, purchasing a commercial license is necessary. You can get all information about pricing and conditions here.

Each Aspose license enables a one-year subscription with free upgrades to any new releases or fixes that are published during this period. Technical support is provided for free unlimitedly both to licensed and evaluation users.

How to Install License

The license is a plain-text XML file that includes details such as the product name, the number of developers it is licensed for, subscription expiry date, and others. The license file is signed digitally, so it must not be modified in any way. Adding even an extra line break into the license file will result in invalidating the license. You need to activate the license to enable the unlimited use of library functions. You only have to enable the license once per application (or process).

The license can be loaded from a stream or file. You need to call the setLicense method of class License to apply the license to the component.

Using Singleton for License Initialization

The most effective way to implement the license is through lazy initialization using the Singleton pattern in your code. Below, we demonstrate how to achieve this with just a few additional lines of code in your project.

public class LicenseSingleton
{
    private static LicenseSingleton instance;
    private LicenseSingleton(String pathToLicenseFile)
    {
      try
      {
      // Initialize the license
       com.aspose.barcode.License license = new com.aspose.barcode.License();
       license.setLicense(pathToLicenseFile);
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    } 
}

public static synchronized void setLicense()
{
    if (instance == null)
    {
      instance = new LicenseSingleton(pathToLicenseFile);
    }
}

You can now initialize the license in your code by simply calling LicenseSingleton.setLicense():

LicenseSingleton.setLicense();
BarCodeReader reader = new BarCodeReader(path, DecodeType.CODE_39_FULL_ASCII);
for (BarCodeResult result : reader.readBarCodes())
{
  System.out.printf("CodeText: %s%n", result.getCodeText());;
  System.out.printf("CodeType: %s%n", result.getCodeType());;
}

Install License From File

com.aspose.barcode.License license = new com.aspose.barcode.License();
license.setLicense(pathToLicenseFile);
or
com.aspose.barcode.License license = new License();
license.setLicense(new File(pathToLicenseFile));

Install License From Stream

License license = new License();
Path filePath = Paths.get(pathToLicenseFile);
try (InputStream inputStream = Files.newInputStream(filePath))
{
  license.setLicense(inputStream);
}
catch (IOException e)
{
  e.printStackTrace();
}