All versions of Minecraft up to and including Minecraft 1.16 will work with Java 8.
Minecraft 1.17 requires Java 16 or higher.
Minecraft 1.18 and above requires Java 17 or higher.
You can get Java either from Oracle or from someone who builds OpenJDK. For the purpose of Minecraft, they are essentially the same, but Oracle's "OTN" version (Oracle JDK uses "Oracle No-Fee Terms and Conditions" as of Java 17 LTS) requires a PAID license for commercial and production purposes. If you make money from streaming Minecraft or running a Minecraft server (even non-profit), you MUST use OpenJDK unless you want to figure out how to pay.
We recommend installing and using Java 17 Zulu OpenJDK which is free and can be downloaded here (.msi installer).
Direct download link for 64-bit Zulu OpenJDK Java 17: https://cdn.azul.com/zulu/bin/zulu17.40.19-ca-jdk17.0.6-win_x64.msi
Direct download link for 32-bit Zulu OpenJDK Java 17: https://cdn.azul.com/zulu/bin/zulu17.40.19-ca-jdk17.0.6-win_i686.msi