License activation
Activate the Nutrient Java SDK license before you run any other SDK operation. This startup step authorizes your application and enables the features tied to your license.
Download sampleActivate a license in the Java SDK
Call License.registerKey() once during startup, before you use other SDK APIs.
Prepare the project
Define a package and class:
package io.nutrient.Sample;Import the required SDK classes:
import io.nutrient.sdk.License;import io.nutrient.sdk.Document;import io.nutrient.sdk.exceptions.NutrientException;
public class LicenseActivation {Create main and declare NutrientException:
public static void main(String[] args) throws NutrientException {Register the license key
Register the key before any other SDK usage:
// Replace the empty string with your license key: License.registerKey("YOUR_LICENSE_KEY_GOES_HERE"); License.registerKey("");After registration, you can call document APIs.
Use the SDK after activation
Use Document inside a try-with-resources statement(opens in a new tab) so Java closes resources automatically:
try (Document document = Document.open("input.pdf")) { document.exportAsPdf("output.pdf"); } }}Trace feature usage in trial mode
Use License.traceFeatures() in trial mode to list the licensed SDK components your application evaluated during the current session. This helps you identify which components a production license needs to cover.
In version 2.1.12, License.traceFeatures() reports every licensed component used in trial mode. Earlier builds could return an empty list or only a single entry.
Handle errors
Nutrient Java SDK raises NutrientException when an SDK call fails. You can declare it in method signatures, as shown above, or catch it with try/catch for custom handling.
Summary
The activation flow has two steps:
- Register the license key.
- Run SDK operations.
Download this sample package to run the example locally.