0

When I do the cmake command the "To be build" section doesn't appear java, what could be the reason for that? I've java installed in my machinewhic

cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=OFF -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-master/modules/ ..

To be built:
core flann imgproc ml photo reg surface_matching video dnn fuzzy
imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect
xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency
text calib3d ccalib datasets rgbd stereo structured_light tracking
videostab xfeatures2d ximgproc aruco optflow stitching python2

Java version

java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

The environment variable is also rightfully set:

echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle/jre/bin/java

references: http://docs.opencv.org/3.1.0/d7/d9f/tutorial_linux_install.html#gsc.tab=0

6
  • Can it find Apache Ant? It seems to be required as well. Just edit the # --- Java Support --- section of the top-level CMakeLists.txt and add a couple of messages to see if the dependency detection finds what's required. Commented Apr 1, 2016 at 1:10
  • yes it does. Thank you the quick reply. I forgot to add this reference as well stackoverflow.com/questions/17386551/… Commented Apr 1, 2016 at 1:12
  • Now that I understood your comment, apparently it could not find JNI I'll have to take a look of that tomorrow. I'll post it then Commented Apr 1, 2016 at 1:19
  • 1
    Hmm, the JAVA_HOME variable, where does it point? Seems like the java binary to me. What if you shorten it to only /usr/lib/jvm/java-8-oracle/ ? Looking at the CMake module FindJNI.cmake, that seems to be the issue. Commented Apr 1, 2016 at 1:24
  • 1
    Thank you Dan you were right. I edited the FindJNI.cmake and added the right path to the JDK and JRE libraries, after that I also needed to change the environment path to not to point to their binaries but to point to JDK and JRE directories so I was able to run ant. Commented Apr 1, 2016 at 19:13

1 Answer 1

0

Solution: Extract JDK to /usr/lib/jvm/jdk1.8.0_77/ set environment variables in /etc/environment and in ~/.profile.

JAVA_HOME="/usr/lib/jvm/jdk1.8.0_77/"
JRE_HOME="/usr/lib/jvm/jdk1.8.0_77/jre/"

add java and javac to /usr/bin

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_77/bin/java" 1000
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_77/bin/javac" 1000

make it sure that they are currently selected:

sudo update-alternatives --config java
sudo update-alternatives --config javac

In the file /usr/share/cmake-3.2/Modules/FindJNI.cmake in the section JAVA_AWT_LIBRARY_DIRECTORIES include

/usr/lib/jvm/jdk1.8.0_77/jre/lib/{libarch}

and in the section JAVA_AWT_INCLUDE_DIRECTORIES include

/usr/lib/jvm/jdk1.8.0_77/include

Install 'ant' and check if /usr/bin/ant -version doesn't say that JAVA_HOME is in the wrong path or something. Finally cmake now should be able to compile libraries for java as well.

Thank you Dan.

addendum:

To compile OpenCv's extra module in java go to CMakeList.txt contained in the directory of the preferred module and add 'java' to the line:

ocv_define_module(face opencv_core opencv_imgproc opencv_objdetect WRAP python java)

Unset BUILD_SHARED_LIBS, BUILD_EXAMPLES, BUILD_TESTS, BUILD_PERF_TESTS, flags and set OPENCV_EXTRA_MODULES_PATH to path: opencv_contrib/modules/.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.