# Sentinel Activation Sample for Java: Readme

## Overview

This sample demonstrates the use of the Sentinel LDK-EMS web services (product key and fetch pending updates using C2V) for the Java programming language.

Sentinel LDK-EMS web services are used in conjunction with various Sentinel Licensing API functions to communicate with the Sentinel LDK-EMS Server.

## Additional Information

If no protection key exists on the user's machine, use the Product Key Activation web service.

If an HL or SL key exists on the machine, use the Fetch Pending Updates by C2V web service. This fetches all pending updates (if such exist), combined into a single package and returned in the V2CP (Vendor-to-Customer package) format.

### Prerequisites

Java SE 8 (JRE 8 and JDK 8).

### Supported Operating Systems and Tested Compilers

Refer to the Sentinel LDK Release Notes - "Supported Platforms for Code Samples" and "Tested Compilers for Code Samples" sections.

## Usage Notes

This section describes how to customize and compile the sample.

### Customizing the Sample

The Sentinel Java Activation sample contains the Sentinel LDK Java samples, together with the Sentinel LDK Java package and the JRE libraries.

To use the Sentinel LDK Java API, copy the JRE libraries and the generated API library to the directory in which the operating system's dynamic libraries are residing.

Under Linux, copy the JRE libraries to one of the following:

- One of the directories specified in the LD_LIBRARY_PATH variable
- /var/hasplm, /usr/local/lib, or /usr/lib

Under macOS, copy the JRE libraries to the following:

- /var/hasplm, /usr/local/lib, or /usr/lib

### Compiling the Sample

Before compiling the samples with `build_samples`, set the JDK environment variable to the path where Java is installed.
For example: `set JDK=p:\java\j2sdk1.8`
To compile the samples, run the build_samples script.
To run the samples, run the run_sample script.

## Description of the Sample Flow

The sample consists of two flows: Product Key Activation and Fetch Pending Updates using C2V.

The steps performed in Product Key Activation flow are as follows:

1. Call the hasp_get_info function to retrieve a fingerprint of the end user's computer.
2. Generate an activation V2C file using the fingerprint together with a Product Key.
3. Call the hasp_update function to apply the V2C file to the end user's computer.

The steps performed in the Fetch Pending Updates using C2V flow are as follows:

1. List the key installed on the user's machine.
2. Fetch the C2V for the selected key and use it to create a web service request for Fetch Pending Updates using C2V.
3. Handle the activation process by calling the LDK-EMS web server, fetching the V2CP, and updating the key using Licensing API.

## Fetching the Header 'polling-frequency' from the Web Service Response

Method fetchPollingFreqFromResponse(HttpURLConnection conn) can be used to read the header polling-frequency value from the web service response.

If you want to write a routine to periodically call the Fetch Pending Updates using C2V web service to check for updates, you can use this value to set the polling frequency.

For more information, see the Sentinel LDK-EMS Web Services Guide.

## Components

The Activation sample contains the following components:

Operating System | Directory or File | Description
--- | --- | ---
All | `classes` | Directory that contains the Activation Sample compiled files
All | `src` | Directory that contains the Activation Java sources
Windows: Mac: Linux: | `build_sample.bat build_sample.sh build_sample.sh` | Batch file for building the Java samples
All | `activation.properties` | This file contains the folllowing properties: LDK-EMS Server URL Product key for activation Customer registration information Modify the properties as required. Save the file using the UTF-8 format.
Windows: Mac: Linux: | `run_sample.bat run_sample.sh run_sample.sh` | Batch file for running the activation sample. Note: (For Windows) If proxy settings are required, update the batch file with this line: (Enter this as a single line of text .Modify the host, port, user, and password parameters as required.) `java -Dhttp.proxyHost=host -Dhttp.proxyPort=port -Dhttp.proxyUser=user -Dhttp.proxyPassword=password -classpath ./classes;hasp-srm-api.jar ActivationSample` For https, replace `Dhttp` with `Dhttps`.
All | `hasp-srm-api.jar` | JAR file with the compiled Sentinel LDK Runtime Java package
Windows: Mac: | `HASPJava.dll libHASPJava.dylib` | Sentinel LDK Runtime JRE library for x86
Windows: Mac: Linux: | `HASPJava_x64.dll libHASPJava.dylib libHASPJava_x86_64.so` | Sentinel LDK Runtime JRE library for x64
Windows: Mac: | `hasp_windows_demo.dll hasp_darwin_demo.dylib` | Sentinel LDK Runtime API library for x86
Windows: Mac: Linux: | `hasp_windows_x64_demo.dll hasp_darwin_demo.dylib libhasp_linux_x86_64.demo.so` | Sentinel LDK Runtime API library for x64

Copyright © 2026 THALES. All rights reserved. Support

DocID 204 Revision 2109-1