com.aspose.words
Class License

java.lang.Object
    extended by com.aspose.words.License

public class License 
extends java.lang.Object

Provides methods to license the component.

Example:

Shows how initialize a license for Aspose.Words using a license file in the local file system.
// Set the license for our Aspose.Words product by passing the local file system filename of a valid license file.
Path licenseFileName = Paths.get(getLicenseDir(), "Aspose.Words.Java.lic");

License license = new License();
license.setLicense(licenseFileName.toString());

// Create a copy of our license file in the binaries folder of our application.
Path licenseCopyFileName = Paths.get(System.getProperty("user.dir"), "Aspose.Words.Java.lic");
FileUtils.copyFile(new File(licenseFileName.toString()), new File(licenseCopyFileName.toString()));

// If we pass a file's name without a path,
// the SetLicense will search several local file system locations for this file.
// One of those locations will be the "bin" folder, which contains a copy of our license file.
license.setLicense("Aspose.Words.Java.lic");

Constructor Summary
License()
           Initializes a new instance of this class.
 
Method Summary
voidsetLicense(java.io.InputStream stream)
           Licenses the component.
voidsetLicense(java.lang.String licenseName)
           Licenses the component.
 

Constructor Detail

License

public License()
Initializes a new instance of this class.

Example:

Shows how initialize a license for Aspose.Words using a license file in the local file system.
// Set the license for our Aspose.Words product by passing the local file system filename of a valid license file.
Path licenseFileName = Paths.get(getLicenseDir(), "Aspose.Words.Java.lic");

License license = new License();
license.setLicense(licenseFileName.toString());

// Create a copy of our license file in the binaries folder of our application.
Path licenseCopyFileName = Paths.get(System.getProperty("user.dir"), "Aspose.Words.Java.lic");
FileUtils.copyFile(new File(licenseFileName.toString()), new File(licenseCopyFileName.toString()));

// If we pass a file's name without a path,
// the SetLicense will search several local file system locations for this file.
// One of those locations will be the "bin" folder, which contains a copy of our license file.
license.setLicense("Aspose.Words.Java.lic");

Method Detail

setLicense

public void setLicense(java.io.InputStream stream)
               throws java.lang.Exception
Licenses the component.

Use this method to load a license from a stream.

Parameters:
stream - A stream that contains the license.

Example:

Shows how to initialize a license for Aspose.Words from a stream.
// Set the license for our Aspose.Words product by passing a stream for a valid license file in our local file system.
try (FileInputStream myStream = new FileInputStream(getLicenseDir() + "Aspose.Words.Java.lic")) {
    License license = new License();
    license.setLicense(myStream);
}

setLicense

public void setLicense(java.lang.String licenseName)
               throws java.lang.Exception
Licenses the component.

Tries to find the license in the following locations:

1. Explicit path.

2. The folder that contains the Aspose component JAR file.

3. The folder that contains the client's calling JAR file.

Parameters:
licenseName - Can be a full or short file name. Use an empty string to switch to evaluation mode.

Example:

Shows how initialize a license for Aspose.Words using a license file in the local file system.
// Set the license for our Aspose.Words product by passing the local file system filename of a valid license file.
Path licenseFileName = Paths.get(getLicenseDir(), "Aspose.Words.Java.lic");

License license = new License();
license.setLicense(licenseFileName.toString());

// Create a copy of our license file in the binaries folder of our application.
Path licenseCopyFileName = Paths.get(System.getProperty("user.dir"), "Aspose.Words.Java.lic");
FileUtils.copyFile(new File(licenseFileName.toString()), new File(licenseCopyFileName.toString()));

// If we pass a file's name without a path,
// the SetLicense will search several local file system locations for this file.
// One of those locations will be the "bin" folder, which contains a copy of our license file.
license.setLicense("Aspose.Words.Java.lic");

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.