How to Set Java Environmental Variables in Linux
Posted by Aly Essa, Last modified by Aly Essa on 29 May 2019 02:32 PM

Overview

FileCatalyst Webmail and Workflow uses Apache Tomcat Server that does require Java to be installed on the machine for the Web Server to access the Java Virtual Machine. Tomcat always looks for the environment variable JRE_HOME that points to the location of Java in the system before the FileCatalyst Webmail or Workflow WAR file is deployed.

In a Linux Operating System, the variable JRE_HOME often is not automatically set or updated after the Java is installed. This issue occurs more frequently when Java was installed through simple extracting files from the installer package or using the TAR file obtained from an Oracle repository.

 

Environment

FileCatalyst Workflow v4.7 and later.

FileCatalyst Webmail v4.7 and later.

Linux Environment.

Oracle Java 7 and later.

 

Resolution

  1. Check if the Java Environment Variables are properly set.
    1. Open a Terminal and run:

      java -version

      If this command returns an error “Command not found” or a similar message, this indicates the PATH variable is not properly set.

  2. To have a more permanent solution that will force the operating system to remember these variables after any restart, the /etc/environment file will need to be edited.
    1. Open the file (/etc/environment) using a text editor such as vi. The file has to be edited using elevated user permissions.
    2. The file may already contain an entry similar to:

      PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin"

      We will need to add the path to the Java bin directory to this list. Assuming your Java RE is located in /opt/java/jre1.8_91/, your modified PATH will look like:

      PATH="/opt/java/jre1.8_91/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin"

    3. Then add a new line with new variable:

      JRE_HOME="/opt/java/jre1.8_91/"

    4. Save the changes and close the file.

  3. Some Linux distributions recommend the addition modified variables to the /etc/profile file.
    1. Open the file /etc/profile using a text editor such as vi. The file has to be edited using elevated user permissions. Add the following lines at the end of the file:

      PATH=/opt/java/jre1.8_91/:$PATH
      JRE_HOME=/opt/java/jre1.8_91/
      export PATH
      export JRE_HOME

    2. Save the changes and close the file. Changes in profile will take effect after the machine is restarted.