Summary

Popular programming language.

Installation on Debian

sudo apt install openjdk-11-jdk

JAVA_HOME

What is?

The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed.

Who uses it?

ref The JAVA_HOME environment variable is not actually used by the locally installed Java runtime. Instead, other programs installed on a desktop computer that require a Java runtime will query the OS for the JAVA_HOME variable to find out where the runtime is installed. After the location of the JDK or JRE installation is found, those programs can initiate Java-based processes, start Java virtual machines and use command line utilities such as the Java archive utility or the Java compiler, both of which are packaged inside the Java installation’s \bin directory.

JAVA_HOME VS JRE_HOME

Java runtime environments can be installed on a computer in one of two ways. The first way is to download and install the JRE, which is a Java runtime environment and nothing else. The second way is to download and install the JDK, which provides both a Java runtime along with a variety of tools that assist in software development. Some programs require only the JRE to function, while others require a full JDK. Programs that only require the JRE will often look for a JRE_HOME, which will point to a JRE installation, rather than look for JAVA_HOME, which should point to a JDK install.

Setting env variable

ref

# jdk will installed at this path in Debian 9
 /usr/lib/jvm/java-11-openjdk-amd64
# in the ~/.profile or /etc/environment
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH

JRE vs JDK

ref