Java is the coding language that Minecraft uses. In order to play Minecraft, you must have Java installed.
Go to your app settings by clicking the cog (⚙️) in the bottom-left. Scroll down to "Java settings". Click "Install recommended" next to both "Java 17 location" and "Java 8 location". Allow some time for both to be downloaded.
Even if there are already values entered for these two fields, we still recommend using the recommended versions. Sometimes, the Java installations already on your system by default will be outdated or the wrong type of Java. For example, if you're playing Minecraft 1.16.5 or older and you encounter an issue saying that you are out of memory, you likely have a 32-bit version of Java when you need a 64-bit version. Using the "Install recommended" button makes sure that you have the correct version.