sdkmanager JAVA_HOME invalid directory

Java
Make sure that the environment variable JAVA_HOME is set to the root
directory of your java runtime environment (JRE) or your java development
kit (JDK) and that there is no semicolon at the end of the directory name.
If there is a semicolon you can remove it by clicking edit or text
Source

Also in Java: