Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve "Could not find JNI", building OpenCV on Raspberry Pi?

I try to build opencv with Java on Raspberry Pi (Debian 4.6.3) and get every time an error from cmake: Could not find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH). I used this documentation (http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html#sbt-project-for-java-and-scala). I have been searching for solution in the Internet for a while. The suggestions were set JAVA_HOME variable, install ant, install python, add ${JAVA_HOME}/bin variable to the PATH variable, set JDK_HOME variable to my jdk1.8.0 home. Unfortunately, nothing has helped me yet. I tried everything, I even tried to completely remove opencv (2.4.6.1) from the Raspberry Pi, download another Version (2.4.6) and build it with cmake - nothing worked. I have two jre's on the Raspberry Pi: one (probably) preinstalled "Java-6-openjdk-armhf" and one, I installed by myself "Java Early Access" (jdk1.8.0 - speciffically for Raspbian with hardfloat). I tried to set JAVA_HOME to "/home/pi/java/jdk1.8.0" (where I installed "Java Early Access") and "/home/pi/java/jdk1.8.0/", The Problem seems to be that cmake cannot find jni.h file, which usually can be found in "JAVA_HOME/include/". I checked this file and I have it; if I type "ls $JAVA_HOME/include" in the shell, I get files with jni.h among them. So, I am out of ideas. Please, help me, if you know how to solve my Problem.

Thanks in advance!

Dmitry

like image 893
Dmitry Obukhov Avatar asked Aug 30 '13 09:08

Dmitry Obukhov


2 Answers

I've finally found the solution of my Problem, so I answer it by myself. As it turned out, cmake checks for System variables of Administrator on Raspberry Pi, I, unfortunately, set JAVA_HOME and ANT_HOME only for my user (not administrator). It seems that if I change file /etc/Profile, the changes will not concern the Administrator and I didn't know that :-(

So, after I set JAVA_HOME and ANT_HOME plus PATH for the Administrator, cmake has found ANT and JNI.

Hope, it will help somebody!

Best regards,

Dmitry

like image 185
user2740142 Avatar answered Nov 11 '22 15:11

user2740142


I had this problem on amazon EC2 and solved it with:

sudo yum install java-1.7.0-openjdk-devel

like image 37
Marco Ponzi Avatar answered Nov 11 '22 16:11

Marco Ponzi