How to configure the JAVA_HOME environment variable in Linux?
To configure the Java Home environment variable, you can follow these steps:
- Open terminal window.
- Select which Java version to use.
- The directory where the Java-X-oracle Java virtual machine is located is /usr/lib/jvm/java-X-oracle.
- The configuration file located in the directory /etc/ where environmental variables are stored.
- Open the file /etc/environment using the nano text editor with superuser privileges.
- The directory containing the Oracle Java-X runtime files is /usr/lib/jvm/java-X-oracle.
- The path to the JAVA_HOME directory is set to “/usr/lib/jvm/java-X-oracle”.
- Save and close the file.
- Read the configuration file located at /etc/environment.
- display the value of the Java installation directory
You have now successfully set up the Java Home environment variable. You can use the $JAVA_HOME variable in the terminal to reference the Java installation path.