CMake could not find JNI
As the CMake version bundled with Android tries to tell you, it can't find the JNI package because some parts were missing:
missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH
Checking the documentation for FindJNI (https://cmake.org/cmake/help/latest/module/FindJNI.html) these variables are set to the locations of libraries and headers not shipped with the Android version of JNI (to little surprise, Android does not included the AWT library for instance).
When running find_package(JNI REQUIRED)
, the FindJNI code checks if these variables are set and if not, issues an error.
A workaround is to set these variables yourself, before calling find_package
:
# We are only interested in finding jni.h: we do not care about extended JVM
# functionality or the AWT library.
set(JAVA_AWT_LIBRARY NotNeeded)
set(JAVA_JVM_LIBRARY NotNeeded)
set(JAVA_INCLUDE_PATH2 NotNeeded)
set(JAVA_AWT_INCLUDE_PATH NotNeeded)
find_package(JNI REQUIRED)
Be aware though, that your code will only be able to use jni.h and its functionality: if it tries to access any other part of the JNI package it will fail (probably at compile time) because essentially, you have tricked CMake into thinking that the entire package was found, when in reality only a part of it exists in the Android setup.
Cmake cannot recognize java while building OpenCv
I don't think this will be the best way to solve this problem, but i solve it this way:
- installing
cmake-gui
(sudo apt-get install cmake-gui
) - removing the content of the build folder (to start again)
- start
cmake-gui
and configure the build - enable
BUILD_JAVA
param - add new entry titled
JAVA_HOME
that points to the java home directory - configure build again
then cmake
successfully recognized java
Build of OpenCV getting errors, are these serious?
you need to work on virtual enviroment restart with
$ mkvirtualenv cv -p python2
Related Topics
Setting/Changing the Ctime or "Change Time" Attribute on a File
Obtaining the Thread Id for Java Threads in Linux
How to Solve the 'Lock Obtain Timed Out' When Using Solr Plainly
Rjava Install Error "Java_Home Cannot Be Determined from the Registry"
How to Support Both Ipv4 & Ipv6 on Java
What Determines the Current Working Directory of Tomcat Java Process
Itext Get Field Coordinates from Existing PDF
Exception in Thread "Main" Java.Lang.Noclassdeffounderror: Org/Apache/Hadoop/Util/Platformname
Cross-Platform Way to Open a File Using Java 1.5
How to Use Chef to Update-Alternatives for Java Using Execute
Why Stringbuilder Stops Adding Elements After Using the Null Character
Eclipse Release Heap Back to System
Problems Installing Java Ee Sdk on Linux
Wireless API for Linux in C or Java
How to Set Addsnapshotlistener and Remove in Populateviewholder in Recyclerview Item
How to Get the First Day of the Current Week and Month