Class TFJ_RuntimeLibrary

java.lang.Object
org.tensorflow.internal.c_api.TFJ_RuntimeLibrary

public final class TFJ_RuntimeLibrary extends Object
Helper class for loading the TensorFlow Java native library.

The Java TensorFlow bindings require a native (JNI) library. This library (libtensorflow_jni.so on Linux, libtensorflow_jni.dylib on OS X, tensorflow_jni.dll on Windows) can be made available to the JVM using the java.library.path System property (e.g., using -Djava.library.path command-line argument). However, doing so requires an additional step of configuration.

Alternatively, the native libraries can be packaged in a .jar, making them easily usable from build systems like Maven. However, in such cases, the native library has to be extracted from the .jar archive.

NativeLibrary.load() takes care of this. First looking for the library in java.library.path and failing that, it tries to find the OS and architecture specific version of the library in the set of ClassLoader resources (under org/tensorflow/native/OS-ARCH). The resources paths used for lookup must be consistent with any packaging (such as on Maven Central) of the TensorFlow Java native libraries.

  • Method Details

    • load

      public static void load()