Ask Your Question

CMake cannot detect latest Apache Ant 1.10.2

asked 2018-02-10 04:58:16 -0600

sid311 gravatar image


I am trying to install OpenCV 3.4 but CMake is unable to detect Apache Ant installed on my machine.

I have it installed in:


When I initially click 'Configure' the output window displays:

ant:                         NO
JNI:                         C:/Program Files/Java/jdk1.8.0_161/include C:/Program Files/Java/jdk1.8.0_161/include/win32 C:/Program Files/Java/jdk1.8.0_161/include
Java wrappers:               NO
Java tests:                  NO

I have installed, however, Java 9.0.4. No matter, that can be changed. But then I am given the new option of 'ANT_EXECUTABLE' in which case I set to:


I have seen others set this option similarly, even though looking at the 'OpenCVDetectApacheAnt.cmake' file seems to looking for a 'ant' (extensionless) file if the system is 64 bit:

    set(ANT_NAME ant.bat)
    set(ANT_NAME ant)

This seems like another case of OpenCV/CMake incorrectly detecting my system as 32bit.

However, if I set ANT_EXECUTABLE to 'C:/apache-ant-1.10.2/bin/ant.bat' and click 'Configure', the output I receive is:

'"java.exe"' is not recognized as an internal or external command, operable program or batch file.

If I set ANT_EXECUTABLE to 'C:/apache-ant-1.10.2/bin/ant' and click 'Configure', the change is seemingly ignored, and I am unable to see the ANT_EXECUTABLE option unless I click 'Configure' again. However, I do get "ANT_ERROR_LEVEL=%1 is not a valid Win32 application" in the CMakeVars.txt file.

Not sure what to do next.

Any help is appreciated.

edit retag flag offensive close merge delete


I uninstalled Java 1.8.0_161 but now CMake won't detect my Java 9.0.4. It is set up correctly in my Paths system variables however. :/

sid311 gravatar imagesid311 ( 2018-02-10 04:59:44 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-02-11 22:38:19 -0600

sid311 gravatar image

It seems to be a system variables issue. Even though I uninstalled Java 1.8.0_161, it left folders behind and paths set in the system variables. CMake detects those and tries to use them.

Removing the folders and system variables allows CMake to find java.exe.

So to reiterate:

ANT_EXECUTABLE to 'C:/apache-ant-1.10.2/bin/ant.bat'


JAVA_HOME = C:\Program Files\Java\jdk-9.0.4

I can't answer my own question for another few hours. :/

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-02-10 04:58:16 -0600

Seen: 3,038 times

Last updated: Feb 10 '18