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.
Added in version 3.24.
JNI::JNIMain JNI target, defined only if jni.h was found.
JNI::AWTJava AWT Native Interface (JAWT) library, defined only if component AWT was
found.
JNI::JVMJava Virtual Machine (JVM) library, defined only if component JVM was found.
JNI::NativeHelperWhen targeting Android API level 31 and above, the import target will provide
access to libnativehelper.so that exposes JVM functions such as
JNI_CreateJavaVM.
This module sets the following result variables:
JNI_INCLUDE_DIRSThe include directories to use.
JNI_LIBRARIESThe libraries to use (JAWT and JVM).
JNI_FOUNDTRUE if JNI headers and libraries were found.
JNI_<component>_FOUNDAdded in version 3.24.
TRUE if <component> was found.
JNI_VERSIONFull Android NDK package version (including suffixes such as -beta3 and
-rc1) or undefined otherwise.
JNI_VERSION_MAJORAdded in version 3.24.
Android NDK major version or undefined otherwise.
JNI_VERSION_MINORAdded in version 3.24.
Android NDK minor version or undefined otherwise.
JNI_VERSION_PATCHAdded in version 3.24.
Android NDK patch version or undefined otherwise.
The following cache variables are also available to set or use:
JAVA_AWT_LIBRARYThe path to the Java AWT Native Interface (JAWT) library.
JAVA_JVM_LIBRARYThe path to the Java Virtual Machine (JVM) library.
JAVA_INCLUDE_PATHThe include path to jni.h.
JAVA_INCLUDE_PATH2The include path to machine-dependent headers jni_md.h and jniport.h.
The variable is defined only if jni.h depends on one of these headers. In
contrast, Android NDK jni.h can be typically used standalone.
JAVA_AWT_INCLUDE_PATHThe include path to jawt.h.