diff --git a/tensorflow/java/src/main/java/org/tensorflow/TensorFlow.java b/tensorflow/java/src/main/java/org/tensorflow/TensorFlow.java index c90655f25dd..a9debb0063d 100644 --- a/tensorflow/java/src/main/java/org/tensorflow/TensorFlow.java +++ b/tensorflow/java/src/main/java/org/tensorflow/TensorFlow.java @@ -63,7 +63,19 @@ public final class TensorFlow { /** Load the TensorFlow runtime C library. */ static void init() { - NativeLibrary.load(); + try { + NativeLibrary.load(); + } catch (Exception e) { + /* + * This code is called during static initialization of this and of other classes. + * If this fails then a NoClassDefFoundError is thrown however this does not + * include a cause. Printing the exception manually here ensures that the + * necessary information to fix the problem is available. + */ + System.err.println("Failed to load TensorFlow native library"); + e.printStackTrace(); + throw e; + } } static {