Troubleshooting: java.lang.UnsatisfiedLinkError

Last Reviewed: August 16, 2018

Article: dts0198

Applies to: dtSearch Engine 6.20 and later

Symptom:

This error occurs running an application that uses the dtSearch Engine's Java API:

java.lang.UnsatisfiedLinkError: no dtsjava in java.library.path

Resolution: Windows (32-bit)

Under Windows, the Java interface to the dtSearch Engine is implemented with three files:

dtSearchEngine.jar, which has the Java classes

dtsjava.dll, a JNI wrapper around the dtSearch Engine's C++ interface

dten600.dll, the dtSearch Engine, which performs the indexing and searching functions

dtSearchEngine.jar must be in one of the folders that is listed in the CLASSPATH environment variable. Adding the dtSearch Engine examples/java/classes folder to the CLASSPATH, or copying its contents to a folder on the CLASSPATH, will make these classes available in Java.

dtsjava.dll and dten600.dll must be in one of the folders that is listed in the PATH environment variable. For instructions on changing the PATH environment variable, see "How to change the system PATH", below. Note that Windows has two PATH variables: one "System" path which applies to all users, and one for the current user. Changes to the current user path may not be visible to some programs, such as services or programs that run in the context of a web server. Therefore, any changes should be made to the System PATH. Usually a reboot is needed for changes to the System PATH to be recognized.

Resolution: Windows (64-bit)

Under Windows, the Java interface to the dtSearch Engine is implemented with three files:

dtSearchEngine.jar, which has the Java classes

dtsjava.dll, a JNI wrapper around the dtSearch Engine's C++ interface (use the one from the dtSearch bin64 folder)

dtengine64.dll, the dtSearch Engine, which performs the indexing and searching functions

dtSearchEngine.jar must be in one of the folders that is listed in the CLASSPATH environment variable. Adding the dtSearch Engine examples/java/classes folder to the CLASSPATH, or copying its contents to a folder on the CLASSPATH, will make these classes available in Java.

dtsjava.dll and dtengine64.dll must be in one of the folders that is listed in the PATH environment variable. For instructions on changing the PATH environment variable, see "How to change the system PATH", below. Note that Windows has two PATH variables: one "System" path which applies to all users, and one for the current user. Changes to the current user path may not be visible to some programs, such as services or programs that run in the context of a web server. Therefore, any changes should be made to the System PATH. Usually a reboot is needed for changes to the System PATH to be recognized.

Both the 32-bit and the 64-bit dtsjava.dll have the same name. The version you use must match the Java version you are using, so under 64-bit Java you should use the 64-bit version of dtsjava.dll. To ensure that the correct version is used with the Java version you have, set the system PATH so the correct dtSearch folder (bin64 or bin) comes first. For example, to use the 64-bit version, set up your system path with C:\Program Files\dtSearch Developer\bin64 ahead of C:\Program Files\dtSearch Developer\bin.

Resolution: Linux

Under Linux, the Java interface to the dtSearch Engine is implemented with two files:

dtSearchEngine.jar, which has the Java classes

libdtsjava.so, which includes both the dtSearch Engine and a JNI wrapper around the dtSearch Engine's C++ interface

libdtsjava.so is the same file as the dtSearch Engine for Linux, which is libdtsearch.so (32-bit) or libdtsearch64.so (64-bit). The makelinks.sh script in the dtsearch/bin folder, and the makelinks64.sh script in the dtsearch/bin64 folder, will create symbolic links so libdtsearch.so will point to the current file.

dtSearchEngine.jar just be in one of the folders that is listed in the CLASSPATH environment variable.

libdtsjava.so must be in a folder that is listed in the LD_LIBRARY_PATH environment variable. You can also copy the dtSearch .so files to your /usr/local/lib folder, or use ldconfig to make them accessible on your system.

The 32-bit and the 64-bit libdtsjava.so have the same name. The version you use must match the Java version you are using, so under 64-bit Java you should use the 64-bit version of libdtsjava.so. To ensure that the correct version is used with the Java version you have, set the LD_LIBRARY_PATH so the correct dtSearch folder (lib64 or lib) comes first.

See also:

dtSearch Java API

How to change the system PATH in Windows

The PATH is a list of folder names that Windows uses to locate executables. The following steps will add the dtSearch program folder to the system PATH.

(1) Click Start > Settings > Control Panel

(2) Click System

(3) Click the Advanced tab.

(4) Click the Environment Variables button

(5) Under System variables, locate the "Path" variable and click on it

(6) Click the Edit button

(7) Add this to the end of the current value (assuming you installed dtSearch to the default location):

;c:\Program Files\dtSearch Developer\bin

The semicolon is needed to separate the dtSearch directory name from the last item listed in the existing PATH.

A reboot may be necessary for some programs to recognize the change to the PATH.