All versions
Java 16
Minecraft 1.17.1 was released on 2021-07-06. 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