Install 2.4.8 onto Raspberry Pi for Java; "Could not find JNI"

asked 2014-03-06 07:15:32 -0500

Will Stewart gravatar image

updated 2014-03-06 14:18:30 -0500

This is in a sense a duplicate of http://answers.opencv.org/question/19817/how-to-resolve-could-not-find-jni-problem-building/ , though he answered his question on StackOverflow without sufficient details for me to follow (I can't figure out how to set JAVA_HOME for administrator beyond setting it in the environment file, and "export" run under root does not show JAVA_HOME or the PATH).

http://stackoverflow.com/questions/18529800/how-to-resolve-could-not-find-jni-building-opencv-on-raspberry-pi

I've tried many different approaches and combinations, however, cmake still cannot find JNI, even after I updated it to find the Include directories as noted in the following;

http://stackoverflow.com/questions/17636166/cmake-find-packagejni-not-work-in-ubuntu-12-04-amd64

I've tried many different combinations, including the Java installation and environment setting at, though it unzips java in /opt/java and recommends setting JAVA_HOME to there;

http://elinux.org/RPi_Java_JDK_Installation

Pertinent FindJNI.cmake lines include;

SET(JAVA_AWT_INCLUDE_DIRECTORIES
  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
  ${_JAVA_HOME}/include
  /usr/include 
  /usr/local/include
  /usr/lib/java/include
  /usr/local/lib/java/include
  /usr/lib/jvm/jdk-7-oracle-armhf/include  <-- Added by me

and

JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
  ${_JAVA_HOME}/jre/lib/{libarch}
  ${_JAVA_HOME}/jre/lib
  ${_JAVA_HOME}/lib
  ${_JAVA_HOME}
  /usr/lib
  /usr/local/lib
  /usr/lib/jvm/java/lib
  /usr/lib/java/jre/lib/{libarch}
  /usr/lib/jvm/jdk-7-oracle-armhf  <-- Added by me
  /usr/lib/jvm/jdk-7-oracle-armhf/lib  <-- Added by me
  /usr/lib/jvm/jdk-7-oracle-armhf/lib/{libarch}  <-- Added by me
  /usr/lib/jvm/jdk-7-oracle-armhf/{libarch}  <-- Added by me

Pertinent OpenCV install script lines include;

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_SHARED_LIBS=OFF  -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON WITH_QT=ON -D WITH_OPENGL=ON ..
make -j 8
sudo make install

Cmake output includes;

-- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY) System is unknown to cmake, create: Platform/error pid:6186, boost::interprocess::bad_alloc Linux to use this system, please send your config file to cmake@www.cmake.org so

I'm at a loss for any more clues to load OpenCV on Raspbian where Java can be used - what else do I need to do?

edit retag flag offensive close merge delete