# Sentinel LDK Licensing API - Java Sample: Readme

This sample demonstrates the use of Sentinel LDK Licensing (Run-time) API when working in the Java language.

## 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.

## Components

This version contains the following components:

Common to All Operating Systems
`hasp_demo.java` | Java hasp_demo program
`hasp_update.java` | Java hasp_update program
Aladdin | Directory containing the Sentinel LDK Java sources
`hasp-srm-api.jar` | JAR file with the compiled Sentinel LDK Java package
`hasp-srm-demo.jar` | JAR file with the compiled Java samples
Windows
`build_samples.bat` | Batch file for building the Java sample
`HASPJava.dll` | JNI library for Win32
`HASPJava_x64.dll` | JNI library for Windows x64
`hasp_windows_demo.dll` | Run-time API DLL for Win32
`hasp_windows_x64_demo.dll` | Run-time API DLL for Windows x64
Mac
`build_samples.sh` | Batch file for building the Java samples
`libHASPJava.dylib` | Universal library containing JNI libraries for various platforms
`libHASPJava.jnilib` | Universal library containing JNI libraries for various platforms
`hasp_darwin_demo.dylib` | Universal binary containing Run-time API dylibs for various platforms
Linux (Intel and ARM)
`build_samples.sh` | Batch file for building the Java samples
`libHASPJava_x86_64.so` | JNI library for Linux x64
`libhasp_linux_x86_64_demo.so` | Run-time API DLL for Linux x64
`libHASPJava_armhf.so` | JNI library for Linux armhf
`libHASPJava_arm64.so` | JNI library for Linux arm64
`libhasp_linux_armhf_demo.so` | Run-time API DLL for Linux armhf
`libhasp_linux_arm64_demo.so` | Run-time API DLL for Linux arm64

## Usage Notes

This section describes how to customize and how to compile the sample.

### Customizing the Sample

The Sentinel LDK Java API package contains the Sentinel LDK Java samples, together with the Sentinel LDK Java package and the JNI libraries.

#### Using the Java API

To use the Sentinel LDK Java API:

1. Copy the JNI libraries and the generated API library to the directory in which the operating system's dynamic libraries reside.

2. Place the Run-time API libraries in one of the following locations on the machine where the protected application is installed.

   - Under Windows:

     - In the process directory (where the application executable resides)

     - In the DLL directory (where the Java DLL resides, if any)

     - In the Windows System directory (for example: c:\Windows\System32\ or c:\Windows\SysWOW64)

     - In the Windows directory (for example: c:\Windows\)

   - Under Linux

     - In the process directory (where the application executable resides)

     - In one of the directories specified in the LD_LIBRARY_PATH variable

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

   - Under macOS

     - In the process directory (where the application executable resides)

     - In one of the directories specified in the LD_LIBRARY_PATH variable

     - In one of the directories specified in the DYLD_LIBRARY_PATH variable

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

   Note: With a language interpreter (such as java.exe), the application is the interpreter itself. In this case, the process directory is the directory where java.exe resides, and not where the Java JAR file resides.

### Compiling the Samples

Before compiling the samples with `build_samples`, set the JDK environment variable to the path where Java is installed.

For example, for Windows, "set `JDK=p:\java\j2sdk1.8`".

To compile the samples, run the `build_samples` script.

### Running the Samples

To run the samples, enter one of the following:

`java hasp_demo`

`java hasp_update`

To run the precompiled samples from the hasp-srm-demo.jar archive under Windows, enter one of the following:

`java -cp .;hasp-srm-api.jar;hasp-srm-demo.jar hasp_demo`

`java -cp .;hasp-srm-api.jar;hasp-srm-demo.jar hasp_update`

To run the precompiled samples from the hasp-srm-demo.jar archive under Mac or Linux, enter one of the following:

`java -cp .:hasp-srm-api.jar:hasp-srm-demo.jar hasp_demo`

`java -cp .:hasp-srm-api.jar:hasp-srm-demo.jar hasp_update`

After you have generated your vendor-specific libraries (using the Master Wizard), copy the C run-time libraries to the folder in which your source code is stored.

## Description of the Sample Flow

The sample consists of several functions. The default flow is as follows:

1. Log into the key.
2. Extract information from the key. The sample reads and writes some information to and from the key.
3. Encrypt and decrypt some test data.

## Prerequisites for Running the Demo

To run the demo, ensure that the following requirements are satisfied:

- If Local only is selected, connect an HL key to the machine or activate an SL key on the machine. Licenses for Feature IDs 1 and 42 must be provided in the protection key to run the demo.

- If Local and local area network is selected, ensure that an HL key with concurrency support is connected to a machine in the local network or that an SL key with concurrency support is activated on a machine in the local network. Licenses for Feature IDs 1 and 42 must be provided in the protection key to run the demo.

- If CL (Identity String-Based Authentication) is selected, make sure the following requirements are satisfied:

1. A CL license is deployed on the cloud license server. A license for Feature ID 1 is required to run the demo.

2. You must obtain an identity string and install it on the machine.

- 4. If CL (OAuth-Based Authentication) is selected, make sure the following requirements are satisfied:

1. A CL is deployed on the Thales-hosted cloud license server. A license for Feature ID 1 is required to run the demo.

2. Enter URIs and client information in the configuration file for Authentication Runtime.

3. Obtain credentials for authentication to Sentinel IDP.

4. Ensure that Authentication Runtime, its configuration file, and a welcome page have been copied to the demo folder.

Refer to the Readme file in the following folder:

%ProgramFiles(x86)%\Thales\Sentinel LDK\Redistribute\Authentication Runtime

Copyright © 2026 THALES. All rights reserved. Support

DocID 104 Revision 2406-1