Configuring environment variables for Apache Tomcat
Apache Tomcat relies on several environment variables to function correctly. Select one of the following operating systems to set the required environment variables:
Determine the installation path of Oracle Java:
Find the path where Oracle Java is installed, such as /usr/lib/jvm/. Use the following command to list the installed JDKs:
For example, if you installed Oracle Java 11, the path is likely: /usr/lib/jvm/jdk-11-oracle-x64.
Determine the installation path of Tomcat:
You can use the find command to locate the Tomcat installation directory:
catalina.sh is stored in the bin directory of the Tomcat installation. The directory containing catalina.sh is the CATALINA_HOME.
Edit the profile file:
Open a terminal and use a text editor to edit the /etc/profile file, which the system uses when users log in. You might need superuser privileges to edit this file.
Add the environment variables and update PATH:
Add the following lines to the end of the /etc/profile file, replacing the path with the actual path to your Oracle Java installation:
Apply the changes:
After saving the file, apply the changes by sourcing the profile file:
Verify the configuration:
To ensure that the environment variables are set correctly and the PATH is updated, check their values with the following commands:
You should see the individual paths set for JAVA_HOME and CATALINA_HOME, as well as their inclusion in the PATH.