> ## Documentation Index
> Fetch the complete documentation index at: https://docs.futurex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure environment variables for Apache Tomcat

> Instructions for setting JAVA_HOME and CATALINA_HOME environment variables for Apache Tomcat.

You must correctly configure the **JAVA\_HOME** environment variable to enable Java applications and tools to locate the installed JDK (Java Development Kit) on your system. Apache Tomcat also requires the **CATALINA\_HOME** environment variable to point to the directory where Tomcat is installed. This section shows how to set the **JAVA\_HOME** and **CATALINA\_HOME** environment variables and update the system **PATH** variable on Linux and Windows operating systems.

<Warning>
  To ensure proper compatibility between Java SunPKCS11 and the Futurex PKCS11 module, you must use Oracle Java and not OpenJDK. Oracle Java 11, 17, and 21 are currently supported.
</Warning>

Select your operating system and follow the instructions:

## Linux

Perform the following steps to configure Tomcat variables in Linux:

<Steps>
  <Step>
    **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:

    ```shell expandable lines wrap title="Shell" theme={null}
    ls /usr/lib/jvm/
    ```

    For example, if you installed Oracle Java 11, the path is likely `/usr/lib/jvm/java-11-openjdk-amd64`.
  </Step>

  <Step>
    **Determine the installation path of Tomcat**:

    You can use the **find** command to locate the Tomcat installation directory:

    ```shell expandable lines wrap title="Shell" theme={null}
    sudo find / -name "catalina.sh"
    ```

    The `catalina.sh` script is located in the `bin` directory of the Tomcat installation. The directory containing `catalina.sh` is the **CATALINA\_HOME**.
  </Step>

  <Step>
    **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.

    ```shell expandable lines wrap title="Shell" theme={null}
    sudo nano /etc/profile
    ```
  </Step>

  <Step>
    **Add the Environment Variables and Update PATH**:

    Add the following lines to the end of the `/etc/profile` file, replacing the paths with your actual installation paths:

    ```shell expandable lines wrap title="Shell" theme={null}
    export JAVA_HOME=/path/to/jdk
    export CATALINA_HOME=/path/to/tomcat
    export PATH=$PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin
    ```
  </Step>

  <Step>
    **Apply the changes**:

    After saving the file, apply the changes by sourcing the profile file:

    ```shell expandable lines wrap title="Shell" theme={null}
    source /etc/profile
    ```
  </Step>

  <Step>
    **Verify the configuration**:

    To ensure that the **JAVA\_HOME** variable is set correctly and the **PATH** is updated, you can check their values with the following commands:

    ```shell expandable lines wrap title="Shell" theme={null}
    echo $JAVA_HOME
    echo $CATALINA_HOME
    echo $PATH
    ```

    You should see the individual paths set for **JAVA\_HOME** and **CATALINA\_HOME**, as well as their inclusion in the **PATH**.
  </Step>
</Steps>

## Windows

Perform the following steps to configure Tomcat variables in Windows:

<Steps>
  <Step>
    **Determine the installation path of Oracle Java**:

    Ensure Oracle Java is installed on your system. Note the installation path, typically something like `C:\Program Files\Java\jdk-11`.
  </Step>

  <Step>
    **Determine the installation path of Tomcat**:

    Ensure Apache Tomcat is installed on your system. Note the installation path. Common default installation paths include `C:\Program Files\Apache Software Foundation\Tomcat` or `C:\Tomcat`.
  </Step>

  <Step>
    **Open System Properties**:

    1. Select the **Win** + **Pause/Break** keys to open the **System Properties** window, or right-click **This PC** (or **My Computer**) and select **Properties**.
    2. Select **Advanced system settings** on the left sidebar.
  </Step>

  <Step>
    **Open Environment Variables**:

    * In the **System Properties** window, select **\[ Environment Variables ]** near the bottom of the window.
  </Step>

  <Step>
    **Create New System Variables**:

    * In the **Environment Variables** window, in the **System variables** section, select **\[ New ]**. This opens the **New System Variable** dialog.
      1. Enter the following for **JAVA\_HOME**:
         * **Variable name**: **JAVA\_HOME**
         * **Variable value**: The path to your JDK installation (such as `C:\Program Files\Java\jdk-11`)
      2. For **CATALINA\_HOME**:
         * **Variable name**: **CATALINA\_HOME**
         * **Variable value**: The path to your Tomcat installation (such as `C:\Program Files\Apache Software Foundation\Tomcat` or `C:\Tomcat`)
  </Step>

  <Step>
    **Update the PATH Variable**:

    1. In the **System variables** section, find and select the **Path** variable, then select **\[ Edit ]**. This opens the **Edit Environment Variable** dialog.
    2. Add new entries:
       1. Select **\[ New ]** and add `%JAVA_HOME%\bin`
       2. Select **\[ New ]** and add `%CATALINA_HOME%\bin`
  </Step>

  <Step>
    **Apply Changes**:

    * Select **\[ OK ]** on each dialog box to apply the changes and exit the dialog boxes.
  </Step>

  <Step>
    **Verify the Configuration**:

    * Open a new **Command Prompt** window (select the **Win + R** keys, type **cmd**, and press Enter).
      1. Enter `echo %JAVA_HOME%` and select the **Enter** key. You should see the path to your JDK installation.
      2. Enter `echo %CATALINA_HOME%` and select the **Enter** key. You should see the path to your Tomcat installation.
      3. Enter `echo %PATH%` and select the **Enter** key. You should see the `JAVA_HOME` and `CATALINA_HOME` environment variables included in the `PATH`.
      4. Enter `java -version` to confirm that the system recognizes the Java installation.
  </Step>
</Steps>
