Senzing Java SDK 4.x Reference Documentation

Jump to Senzing SDK Packages

Maven Usage

The sz-sdk.jar is not provided via Maven Central. Rather, you can use the version provided with the Senzing product as a system-scoped dependency:
<dependency>
    <groupId>com.senzing</groupId>
    <artifactId>sz-sdk</artifactId>
    <version>${SENZING_VERSION}</version>
    <scope>system</scope>
    <systemPath>${SENZING_PATH}/er/sdk/java/sz-sdk.jar</systemPath>
</dependency>
The SENZING_VERSION and SENZING_PATH properties in the above example can be set as environment variables, set in the pom.xml's <properties> section or replaced with their literal values directly.
While using a system-scoped dependency is straight-forward, it has been deprecated by Apache Maven. Alternatively, you can install the sz-sdk.jar in your local Maven repository and simply use the following:
<dependency>
    <groupId>com.senzing</groupId>
    <artifactId>sz-sdk</artifactId>
    <version>${SENZING_VERSION}</version>
</dependency>

Installation in Local Maven Repository

The mvn install:install-file command can be used to install a jar file in your local repository. To simplify this, version 4.1.0 (or newer) of sz-sdk.jar doubles as an executable jar file and you can use java -jar sz-sdk.jar to generate the Apache Maven command to achieve this on your system.
USAGE: java -jar sz-sdk.jar [options]

Options:
 [none]    : Output the Maven command-line for installing sz-sdk.jar in your
             local file-system Maven repository (e.g.: [home]/.m2/repository).

 -h        : Display this help message (must be the only option specified).

 -d        : Display Senzing install info (must be the only option specified).

 -x        : Attempt to execute the generated Maven install command.
             NOTE: This requires Maven is installed and found in the path

 -r <path> : Optionally specify the path to the local Maven repository.
             NOTE: Omit to use the default (e.g.: [home]/.m2/repository)
You can simply generate the Apache Maven command, inspect it, copy it and execute it. Or (assuming the mvn executable is in your path) you can use the -x option to have the sz-sdk.jar install itself for you.

Native Dependencies

The com.senzing.sdk.core.SzCoreEnvironment implementation of com.senzing.sdk.SzEnvironment has native dependencies as its functionality is implemented in native code. To use it, you will need to ensure the Senzing native libraries are in the library path as follows:
Linux
Set the LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=$SENZING_PATH/er/lib:$LD_LIBRARY_PATH
Assuming installation in the the default location:
export LD_LIBRARY_PATH=/opt/senzing/er/lib:$LD_LIBRARY_PATH
macOS
Set the DYLD_LIBRARY_PATH:
export DYLD_LIBRARY_PATH=$SENZING_PATH/er/lib:$SENZING_PATH/er/lib/macos:$DYLD_LIBRARY_PATH
Assuming installation in the user home directory:
export DYLD_LIBRARY_PATH=$HOME/senzing/er/lib:$HOME/senzing/er/lib/macos:$DYLD_LIBRARY_PATH
NOTE: As part of macOS's System Integrity Protection (SIP) implementation the DYLD_LIBRARY_PATH variable is never inherited for "system" executables. As such, your JAVA_HOME and PATH environment variables should point to a Java installation in your home directory.
Windows
Set the Path:
set Path=%SENZING_PATH%\er\lib;%Path%
Assuming installation in the user home directory:
set Path=%USERPROFILE%\senzing\er\lib;%Path%

NOTE: It is not sufficient to set the java.library.path system property. The Senzing native library (i.e.: libSz.so on Linux, libSz.dylib on macOS or Sz.dll on Windows) has dependencies on other Senzing-provided native libraries that must be in the library path and the native code has no access to the java.library.path system property.


Code Snippets

Example code snippets are referenced in the relevant method documentation; however, all example code snippets can be found here.

Version Differences

For each class, method, constant and field, the "Since" annotation will designate the Senzing version in which the respective element was introduced.

Packages
Package
Description
This package provides the interfaces, utility classes, enumerations, constants and exception types pertaining to the Senzing SDK for Java.
This package provides the "core" implementation of the Senzing SDK for Java defined in the com.senzing.sdk package.