FindJava: fails to find required Java 17 when Java 11 is also present
Both Java versions are installed:
$ pkg info | grep jdk
bootstrap-openjdk11-11.0.5.10.1 Java Development Kit 11
openjdk11-11.0.18+10.1 Java Development Kit 11
openjdk17-17.0.6+10.1 Java Development Kit 17
This cmake code fails:
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
find_package(Java 17 REQUIRED COMPONENTS Runtime)
CMake Error at /usr/local/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Java: Found unsuitable version "11.0.18", but required is at
least "17" (found /usr/local/bin/java, found components: Runtime)
Call Stack (most recent call first):
/usr/local/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:598 (_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake/Modules/FindJava.cmake:314 (find_package_handle_standard_args)
CMakeLists.txt:3 (find_package)
cmake-core-3.25.1 OS: FreeBSD 13.1
(I think I've already reported this bug a year ago, but I couldn't find it now.)
Edited by yurivict