The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed.
Open /etc/environment in the text editor and add the following line:
Syntax:
JAVA_HOME="path_to_java_folder"
Example:
JAVA_HOME="/usr/lib/jvm/java-1.11.0-openjdk-amd64"
Reload /etc/environment by running the following command.
source /etc/environment
Show JAVA_HOME environment variable
echo $JAVA_HOME