Last Updated: February 25, 2016
·
5.627K
· TomTasche

CMake Error: Could NOT find JNI (missing: JAVA_INCLUDE_PATH2)

this error suddenly popped up after upgrading to Mac OSX 10.10. after a long time searching for a solution I found out that cmake already fixed this with CMake 3.0+ (I was using 2.8-something): http://public.kitware.com/Bug/view.php?id=14508

the error looked something like this:

CMake Error at             target/dependency/cmake/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
        Could NOT find JNI (missing: JAVA_INCLUDE_PATH2)

a workaround would be to add the following lines to your CMakeLists.txt:

if(APPLE)
    SET(JAVA_INCLUDE_PATH2 "$ENV{JAVA_HOME}/include")
endif()

because cmake 3.0+ currently doesn't build using homebrew on OS X 10.10