Repository: opencv
Issue: OpenCV 4.5.5 / Visual Studio 2022 - Java Wrappers are not built
Labels: question (invalid tracker),category: build/install,category: java bindings

<!--
If you have a question rather than reporting a bug please go to https://forum.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->

##### System information (version)
- OpenCV => 4.5.5
- Operating System / Platform => Windows 11 64 Bit
- Compiler => Visual Studio 2022 (vc 17)
- Java: Open JDK 17.0.2
- Ant: 1.10.12

##### Detailed description

When building OpenCV 4.5.5 from sources, even if Ant and JNI are well detected, the java module is marked as unavailable and is not built. The script i use for buiding OpenCV 4.5.5 with java wrappers works fine with OpenCV 4.5.5 / Visual Studio 2019

##### Steps to reproduce
Here is my CMake Command:

cmake -G"Visual Studio 17 2022" -T"v143,host=x64" -DBUILD_opencv_python:BOOL=OFF -DBUILD_opencv_python2:BOOL=OFF -DBUILD_opencv_python3:BOOL=OFF -DBUILD_opencv_world:BOOL=ON -DBUILD_JAVA:BOOL=ON -DBUILD_opencv_java:BOOL=ON -DBUILD_opencv_java_bindings_generator:BOOL=ON -DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DOPENCV_ENABLE_NONFREE:BOOL=ON -DBUILD_DOCS:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=OFF   -DWITH_CUDA:BOOL=OFF -DWITH_CUBLAS:BOOL=OFF -DOPENCV_EXTRA_MODULES_PATH=D:\jse\dev\opencv\4.5.5\opencv-java\git\opencv_contrib\modules -DCMAKE_INSTALL_PREFIX=..\..\install\opencv D:\jse\dev\opencv\4.5.5\opencv-java\git\opencv

I've downloaded OpenCV 4.5.5 and OpenCV Contrin 4.5.5 from GITHUB.

Filtered part of the output log does not raises error:

```
[...]
-- 'Release' build type is used by default. Use CMAKE_BUILD_TYPE to specify build type (Release or Debug)
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22000.
-- The CXX compiler identification is MSVC 19.31.31104.0
-- The C compiler identification is MSVC 19.31.31104.0
[...]
-- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.7")
-- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3.2")
[...]
-- Performing Test HAVE_C_STD_C99
-- Performing Test HAVE_C_STD_C99 - Failed
[...]
-- Found apache ant: D:/programs/ant/apache-ant-1.10.12/bin/ant.bat (1.10.12)
-- Found JNI: D:/programs/java/jdk-17.0.2/lib/jawt.lib  
[...]
-- General configuration for OpenCV 4.5.5 =====================================
--   Version control:               4.5.5
-- 
--   Extra modules:
--     Location (extra):            D:/jse/dev/opencv/4.5.5/opencv-java/git/opencv_contrib/modules
--     Version control (extra):     4.5.5
-- 
--   Platform:
--     Timestamp:                   2022-03-18T06:18:36Z
--     Host:                        Windows 10.0.22000 AMD64
--     CMake:                       3.22.3
--     CMake generator:             Visual Studio 17 2022
--     CMake build tool:            C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe
--     MSVC:                        1931
--     Configuration:               Debug Release
-- 
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (16 files):         + SSSE3 SSE4_1
--       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (0 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (4 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (31 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (5 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
-- 
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ standard:                11
--     C++ Compiler:                C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe  (ver 19.31.31104.0)
--     C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP  /MT /O2 /Ob2 /DNDEBUG 
--     C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP  /MTd /Zi /Ob0 /Od /RTC1 
--     C Compiler:                  C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe
--     C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP   /MT /O2 /Ob2 /DNDEBUG 
--     C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP /MTd /Zi /Ob0 /Od /RTC1 
--     Linker flags (Release):      /machine:x64  /NODEFAULTLIB:atlthunk.lib /INCREMENTAL:NO  /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:libcpmtd.lib /NODEFAULTLIB:msvcrtd.lib
--     Linker flags (Debug):        /machine:x64  /NODEFAULTLIB:atlthunk.lib /debug /INCREMENTAL  /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:msvcrt.lib
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          comctl32 gdi32 ole32 setupapi wsock32 ws2_32
--     3rdparty dependencies:       libprotobuf libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf zlib quirc ade ittnotify ippiw ippicv
-- 
--   OpenCV modules:
--     To be built:                 alphamat aruco barcode bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab wechat_qrcode world xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    -
--     Disabled by dependency:      -
--     Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java julia matlab ovis python2 python3 sfm ts viz
--     Applications:                apps
--     Documentation:               NO
--     Non-free algorithms:         YES
-- 
--   Windows RT support:            NO
-- 
--   GUI: 
--     Win32 UI:                    YES
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        build (ver 1.2.11)
--     JPEG:                        build-libjpeg-turbo (ver 2.1.2-62)
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         build (ver 1.6.37)
--     TIFF:                        build (ver 42 - 4.2.0)
--     JPEG 2000:                   build (ver 2.4.0)
--     OpenEXR:                     build (ver 2.3.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      YES (prebuilt binaries)
--       avcodec:                   YES (58.134.100)
--       avformat:                  YES (58.76.100)
--       avutil:                    YES (56.70.100)
--       swscale:                   YES (5.9.100)
--       avresample:                YES (4.0.0)
--     GStreamer:                   NO
--     DirectShow:                  YES
--     Media Foundation:            YES
--       DXVA:                      YES
-- 
--   Parallel framework:            Concurrency
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Intel IPP:                   2020.0.0 Gold [2020.0.0]
--            at:                   D:/jse/dev/opencv/4.5.5/opencv-java/build/opencv/3rdparty/ippicv/ippicv_win/icv
--     Intel IPP IW:                sources (2020.0.0)
--               at:                D:/jse/dev/opencv/4.5.5/opencv-java/build/opencv/3rdparty/ippicv/ippicv_win/iw
--     Lapack:                      NO
--     Eigen:                       YES (ver 3.3.9)
--     Custom HAL:                  NO
--     Protobuf:                    build (3.19.1)
-- 
--   OpenCL:                        YES (NVD3D11)
--     Include path:                D:/jse/dev/opencv/4.5.5/opencv-java/git/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python (for build):            NO
-- 
--   Java:                          
--     ant:                         D:/programs/ant/apache-ant-1.10.12/bin/ant.bat (ver 1.10.12)
--     JNI:                         D:/programs/java/jdk-17.0.2/include D:/programs/java/jdk-17.0.2/include/win32 D:/programs/java/jdk-17.0.2/include
--     Java wrappers:               NO
--     Java tests:                  NO
[...]
```

You can find the complete log in attached.

##### Issue submission checklist

 - [x ] I report the issue, it's not a question

 - [ x] I checked the problem with documentation, FAQ, open issues,
       forum.opencv.org, Stack Overflow, etc and have not found any solution

 - [ x] I updated to the latest OpenCV version and the issue is still there

 - [ x] There is reproducer code and related data files: videos, images, onnx, etc


[build.log](https://github.com/opencv/opencv/files/8302139/build.log)