Ask Your Question

fatal error: 'jni.h' file not found

asked 2016-12-05 14:08:18 -0600

jcrist gravatar image

updated 2016-12-05 14:20:23 -0600


I encountered really strange issue, which appeared recently most likely due to XCode/Java updates. Here is my setup:

  • OSX EL Capitan 10.11.6
  • Xcode Version 8.1 (8B62)
  • java version "1.8.0_111"
  • Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
  • Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

My codebase is: commit 6c12533160bc5e6de1f09847d9cd6dd548667a55 Merge: 811eb76 bec3479 Author: Alexander Alekhin [email protected] Date: Mon Oct 31 17:35:41 2016 +0000

Previously I was able to build opencv master from sources with no issues but when I'm trying to build it now, it cannot find jni.h!:

/opencv/modules/java/generator/src/cpp/common.h:8:10: fatal error: 'jni.h' file not found
#include <jni.h>

Appreciate any ideas or hints how to fix this? JAVA_HOME is pointing at correct folder and also include folder is there and jni.h is where it should be ...

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-12-05 14:34:05 -0600

jcrist gravatar image

Found the answer. For some reason the path to old JDK was preserved in the cmake settings so it was pointing to non-existing folder. Here is the fix:

  1. run ccmake .. in opencv/build folder
  2. toggle advanced mode (press 't')
  3. found and changed JNI paths.

This is just in case if anybody will face the similar problem after upgrade of xcode/jdk.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-12-05 14:08:18 -0600

Seen: 1,814 times

Last updated: Dec 05 '16