本文介绍了在Raspberry Pi上构建OpenCV时,如何解决“找不到JNI"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Raspberry Pi(Debian 4.6.3)上用Java构建opencv,并每次从cmake中得到一个错误:找不到JNI(丢失:JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH).我使用了此文档( http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html#sbt-project-for-java-and-scala ).我一直在互联网上寻找解决方案.建议设置为JAVA_HOME变量,安装ant,安装python,将$ {JAVA_HOME}/bin变量添加到PATH变量,将JDK_HOME变量设置为我的jdk1.8.0主页.不幸的是,没有任何帮助.我尝试了所有操作,甚至尝试从Raspberry Pi中完全删除opencv(2.4.6.1),下载另一个版本(2.4.6)并使用cmake进行构建-没有任何效果.我在Raspberry Pi上有两个jre:一个(可能)预装了"Java-6-openjdk-armhf",另一个是我自己安装了"Java Early Access"(jdk1.8.0-特别是对于具有hardfloat的Raspbian).我试图将JAVA_HOME设置为"/home/pi/java/jdk1.8.0"(我在其中安装了"Java Early Access")和"/home/pi/java/jdk1.8.0/",问题似乎出在cmake上.找不到jni.h文件,该文件通常可以在"JAVA_HOME/include/"中找到.我检查了这个文件,便有了它;如果在外壳程序中键入"ls $ JAVA_HOME/include",则将获得jni.h文件.所以,我没主意了.请帮助我,如果您知道如何解决我的问题.

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.

提前谢谢!

德米特里

推荐答案

我终于找到了问题的解决方案,所以我自己回答.事实证明,cmake在Raspberry Pi上检查Administrator的系统变量,很不幸,我仅为我的用户(不是管理员)设置JAVA_HOME和ANT_HOME.看来,如果我更改文件/etc/Profile,更改将与管理员无关,并且我也不知道:-(

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 :-(

因此,在为管理员设置JAVA_HOME和ANT_HOME以及PATH之后,cmake已找到ANT和JNI.

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!

最诚挚的问候,

德米特里

这篇关于在Raspberry Pi上构建OpenCV时,如何解决“找不到JNI"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 08:26