What is Java_Home?
It is an environment variable that is nothing but a location or directory where after the installation of Java on Linux, Windows, or mac we can find the java executables such as java, javac, and keytool. Being an environment variable, we don’t need to mention the folder path again and again where Java has been installed to use any of its executable files.
However, sometimes while installing some software platforms or creating systemd service unit files, we need to mention the location or Java_Home path manually in them. Hence, for those who don’t where exactly the path is, we can use the below-given command in our respective Linux operating system to find it.
Command to find Java_home on Linux distros
The following given commands will work on all Linux systems installed with java.
Use the find command to get Java_Home
Here is the find command that will use your current user directories to find the folders with JDK in them. Hence, in short with this you will get all the available Java_home even of different versions.
sudo find /usr/ -name *jdk
The next command uses Java itself to find the path
java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home'