FindJNI¶
Find Java Native Interface (JNI) headers and libraries.
JNI enables Java code running in a Java Virtual Machine (JVM) or Dalvik Virtual Machine (DVM) on Android to call and be called by native applications and libraries written in other languages such as C and C++.
This module finds if Java is installed and determines where the
include files and libraries are.  It also determines what the name of
the library is.  The caller may set variable JAVA_HOME to specify a
Java installation prefix explicitly.
Added in version 3.24: Added imported targets, components AWT, JVM, and Android NDK support.
If no components are specified, the module defaults to an empty components
list while targeting Android, and all available components otherwise.
When using Android NDK, the corresponding package version is reported and a
specific release can be requested. At Android API level 31 and above, the
additional NativeHelper component can be requested. NativeHelper is
also exposed as an implicit dependency of the JVM component (only if this
does not cause a conflict) which provides a uniform access to JVM functions.
Imported Targets¶
Added in version 3.24.
- JNI::JNI
- Main JNI target, defined only if - jni.hwas found.
- JNI::AWT
- Java AWT Native Interface (JAWT) library, defined only if component - AWTwas found.
- JNI::JVM
- Java Virtual Machine (JVM) library, defined only if component - JVMwas found.
- JNI::NativeHelper
- When targeting Android API level 31 and above, the import target will provide access to - libnativehelper.sothat exposes JVM functions such as- JNI_CreateJavaVM.
Result Variables¶
This module sets the following result variables:
- JNI_INCLUDE_DIRS
- The include directories to use. 
- JNI_LIBRARIES
- The libraries to use (JAWT and JVM). 
- JNI_FOUND
- TRUEif JNI headers and libraries were found.
- JNI_<component>_FOUND
- Added in version 3.24. - TRUEif- <component>was found.
- JNI_VERSION
- Full Android NDK package version (including suffixes such as - -beta3and- -rc1) or undefined otherwise.
- JNI_VERSION_MAJOR
- Added in version 3.24. - Android NDK major version or undefined otherwise. 
- JNI_VERSION_MINOR
- Added in version 3.24. - Android NDK minor version or undefined otherwise. 
- JNI_VERSION_PATCH
- Added in version 3.24. - Android NDK patch version or undefined otherwise. 
Cache Variables¶
The following cache variables are also available to set or use:
- JAVA_AWT_LIBRARY
- The path to the Java AWT Native Interface (JAWT) library. 
- JAVA_JVM_LIBRARY
- The path to the Java Virtual Machine (JVM) library. 
- JAVA_INCLUDE_PATH
- The include path to - jni.h.
- JAVA_INCLUDE_PATH2
- The include path to machine-dependant headers - jni_md.hand- jniport.h. The variable is defined only if- jni.hdepends on one of these headers. In contrast, Android NDK- jni.hcan be typically used standalone.
- JAVA_AWT_INCLUDE_PATH
- The include path to - jawt.h.
