Generally, this is what you want to know: - Minecraft 1.17 and newer: Java 21 - Minecraft 1.16.5 and older: Java 8
Note: some modded Minecraft versions require a different Java runtime than normal (e. g. Cursed Fabric or Babric for Minecraft b1.7.3). Others might work even when using a different runtime (e. g. Fabric for Minecraft 1.16.5 allows using Java 17). However, some mods, notably OptiFabric, might stop working altogether.