Monday, May 13, 2013

OpenCV build: "Could NOT find JNI" (Ubuntu)

While trying to build OpenCV so I could use the new Java bindings, I kept getting this somewhat confusing message:
Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY)

What does it mean - did I need to set environment variables for the AWT and JVM libraries? Surely they're both already installed. What does it even mean to say "Could NOT find JNI", since JNI is a part of Java which is installed?

Turns out I needed to manually set the JAVA_HOME environment variable:
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
Why Ubuntu doesn't automatically set this when you install the openjdk7 package, I have no idea.