FindJNI.cmake will not respect JAVA_HOME if a different JDK is in the System PATH, not even if the JDF in PATH is a different JAVA version and EXACT is specified
I ran into two problems with the FindJNI module with CMake 3.14.1 on Windows 10/64 bit:
- Instead of finding the JDK in the JAVA_HOME variable (as it should according to the documentation), it finds the one in the PATH variable. This is more or less the same problem as #13942.
- Even with find_package(JNI 1.8 EXACT REQUIRED) it still finds the JDK 1.11 in my system PATH.
I could fix the first issue myself by introducing if blocks in a couple of places with the HINTS keyword - not sure if this is the best solution, but it works for me (see attached file).
if ( ${_JAVA_HOME_EXPLICIT} )
# Use "HINTS" if JAVA_HOME is set explicitely
set(_JNI_NORMAL_JVM
NAMES jvm
HINTS ${JAVA_JVM_LIBRARY_DIRECTORIES}
)
Best regards Christopher