It's 2023 now and if you have linux and a program called 'alternatives' you can use the cmd
$> alternatives --config java
to find path to java versions on your machine and this program lets you choose which version you want to use if you have more than 1 java installed.
Then the docs at:
Apache Hadoop 3.3.4 – Hadoop: Setting up a Single Node Cluster.
give pretty clear instruction as to which files need variables adjusted. For my hadoop 3.1 I had to set JAVA_HOME in the hadoop-env.sh file. Read the docs!