All versions
Java 16
Minecraft 1.17 was released on 2021-06-08. Mojang's version file lists Java 16 for it, for both the game and a server.
See which Java you have:
java -version
Download Java 16 from Adoptium