> ## 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.

# Configuring environment variables for Apache Tomcat

> Instructions for setting required environment variables for Apache Tomcat on Linux or Windows.

Apache Tomcat relies on several environment variables to function correctly. Select one of the following operating systems to set the required environment variables:

## Linux

Perform the following steps to configure environment 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/jdk-11-oracle-x64.`
  </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"
    ```

    `catalina.sh` is stored 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 path with the actual path to your Oracle Java installation:

    ```none expandable lines wrap title="None" theme={null}
    export JAVA_HOME=/path/to/jdk
    export CATALINA_HOME=/path/to/tomcat
    export LD_LIBRARY_PATH=/usr/local/bin/fxpkcs11/libfxpkcs11.so 
    export FXPKCS11_CFG=/etc/fxpkcs11.cfg
    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 environment variables are set correctly and the `PATH` is updated, check their values with the following commands:

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

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

## Windows

Perform the following steps to configure environment 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 similar to `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**:

    Select the **Win + Pause/Break** keys to open the **System Properties** window, or right-click **This PC**(or **My Computer**) and select **Properties**.

    Go to **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, under the **System Variables** section, select **\[ New ]**.

    * For **JAVA\_HOME**:
      * Variable name: **JAVA\_HOME**
      * Variable value: The path to your JDK installation (such as `C:\Program Files\Java\jdk-11`)
    * 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`)
    * For **LD\_LIBRARY\_PATH**:
      * Variable name: **LD\_LIBRARY\_PATH**
      * Variable value: The path to your FXPKCS11 library (such as `C:\Program Files\Futurex\fxpkcs11\fxpkcs11.dll`)
    * For **FXPKCS11\_CFG**:
      * Variable name: **FXPKCS11\_CFG**
      * Variable value: The path to your FXPKCS11 configuration file (such as `C:\Program Files\Futurex\fxpkcs11\fxpkcs11.cfg`)
  </Step>

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

    In the **System Variables** section, find and select the **Path** variable, and select **\[ Edit ]**.

    Add new entries:

    * Select **\[ New ]** and add **%JAVA\_HOME%\bin**
    * Select **\[ New ]** and add **%CATALINA\_HOME%\bin**
  </Step>

  <Step>
    **Apply the 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 (press **Win + R**, type **cmd**, and select the **Enter** key).

    * Enter `echo %JAVA_HOME%` and select the **Enter** key. You should see the path to your JDK installation.
    * Enter `echo %CATALINA_HOME%` and select the **Enter** key. You should see the path to your Tomcat installation.
    * Enter `echo %LD_LIBRARY_PATH%` and select the **Enter** key. You should see the path to the Futurex PKCS #11 module.
    * Enter `echo %FXPKCS11_CFG%` and select the **Enter** key. You should see the path to the Futurex PKCS #11 configuration file.
    * Enter `echo %PATH%` and select the **Enter** key. You should see the **JAVA\_HOME** and **CATALINA\_HOME** environment variables included in the **PATH**.
    * Enter `java -version` to confirm that the system recognizes the Java installation.
  </Step>
</Steps>
