# Installing Java

On the Caplin Platform, a Java runtime environment (JRE) is used to run Java-based DataSources (integration adapters) and to run Java modules in C-based DataSources. This page provides an overview of the steps required to install a Caplin Platform compatible JRE on Red Hat Linux, Microsoft Windows, and macOS.

## JRE compatibility

The most recent versions of Caplin Platform 7.1 components are compatible with Oracle Java 8 (\&lt;=8u202), Red Hat OpenJDK 8, and Red Hat OpenJDK 11.

For detailed information JRE compatibility, see [Caplin Platform System Requirements](../platform-architecture/platform-hardware-and-software-requirements.md).

## Installing Java on Red Hat Enterprise Linux

To install Red Hat OpenJDK 11 (available in RHEL 7), follow the steps below:

1. Install Red Hat OpenJDK 11:

   ```
   $ sudo yum install java-11-openjdk-devel
   ```
2. In the home directory of the user account used to run Caplin Platform components, edit the file `~/.bash_profile` and set the JAVA_HOME variable to the value below:

   ```
   export JAVA_HOME=/etc/alternatives/java_sdk_11
   ```
3. Run the command below and select OpenJDK 11 as the JDK that provides the `**javac**` command on the command line:

   ```console
   $ sudo alternatives --config javac
   ```
4. Run the command below and select OpenJDK 11 as the JRE that provides the `**java**` command on the command line:

   ```console
   $ sudo alternatives --config java
   ```

<details>
<summary>Installing Red Hat OpenJDK 8</summary>

To install Red Hat OpenJDK 8 (available in RHEL 6 and RHEL 7), follow the steps below:

1. Install Red Hat OpenJDK 8:

   ```
   $ sudo yum install java-1.8.0-openjdk-devel
   ```
2. In the home directory of the user account used to run Caplin Platform components, edit the file `~/.bash_profile` and set the JAVA_HOME variable to the value below:

   ```
   export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0
   ```
3. Run the command below and select OpenJDK 8 as the JDK that provides the `**javac**` command on the command line:

   ```console
   $ sudo alternatives --config javac
   ```
4. Run the command below and select OpenJDK 8 as the JRE that provides the `**java**` command on the command line:

   ```console
   $ sudo alternatives --config java
   ```

</details>

<details>
<summary>Installing Oracle Java 8</summary>

To install Oracle Java 8 (8u202), follow the steps below:

1. From the Oracle website, download the RPM for Oracle JDK 8 64-bit (8u202).

   **❗ IMPORTANT**\
   Versions of the Oracle JDK 8 greater than update 202 (8u202) require a licence for commercial use. For more information, see the [Oracle Java SE Licensing FAQ](https://www.oracle.com/uk/java/technologies/javase/jdk-faqs.html) on the Oracle website.
2. Install the RPM:

   ```console
   $ sudo yum install ./jdk-<version>-linux-x64.rpm
   ```
3. In the home directory of the user account used to run Caplin Platform components, edit the file `~/.bash_profile` and set the JAVA_HOME variable to the value below:

   ```
   JAVAC_PATH=$(readlink -f /etc/alternatives/javac)
   export JAVA_HOME=${JAVAC_PATH%/bin/javac}
   ```
4. Run the command below and select the Oracle JDK 8 as the JDK that provides the `**javac**` command on the command line:

   ```console
   $ sudo alternatives --config javac
   ```
5. Run the command below and select the Oracle JDK 8 as the JRE that provides the `**java**` command on the command line:

   ```console
   $ sudo alternatives --config java
   ```
6. Log off and log back in to your account.
</details>

## Installing Java on Microsoft Windows

To install OpenJDK 11 on Microsoft Windows, follow the steps below:

1. Download the Adoptium OpenJDK 11 installer from the [Adoptium](https://adoptium.net/) website.
2. Run the installer, and, when prompted, enable the following installation options:
   * Add to PATH
   * Set JAVA_HOME

<details>
<summary>Installing OpenJDK 8</summary>

To install OpenJDK 8 on Microsoft Windows, follow the steps below:

1. Download the Adoptium OpenJDK 8 installer from the [Adoptium](https://adoptium.net/) website.
2. Run the installer, and, when prompted, enable the following installation options:
   * Add to PATH
   * Set JAVA_HOME
</details>

<details>
<summary>Installing Oracle Java 8</summary>

To install Oracle Java 8 (8u202), follow the instructions below:

1. Download and install the Oracle JDK 8 (8u202) from the Oracle website.

   **❗ IMPORTANT**\
   Versions of the Oracle JDK 8 greater than update 202 (8u202) require a licence for commercial use. For more information, see the [Oracle Java SE Licensing FAQ](https://www.oracle.com/uk/java/technologies/javase/jdk-faqs.html) on the Oracle website.
2. On your keyboard, press Windows + Pause to open the System window
3. In the System window, navigate to **Advanced system settings > Environment Variables**
4. Set the value of the `JAVA_HOME` system environment variable to the full path to the JDK’s directory. For example: `C:\Program Files (x86)\Java\jdk1.8.0_60`
5. Append the JDK’s `bin` subdirectory to the PATH system environment variable, using a semi-colon to separate it from the preceding paths.

   **💡 TIP**\
   You can reference the JAVA_HOME variable when specifying the location of the JDK’s `bin` subdirectory. For example: `%JAVA_HOME%\bin`

</details>

## Installing Java on Apple macOS

To install OpenJDK 11 on macOS, follow the steps below:

1. Download the Adoptium OpenJDK 11 from the [Adoptium](https://adoptium.net/) website.
2. Follow the [macOS PKG installer packages](https://adoptium.net/installation/macos/) instructions on the Adoptium website.

<details>
<summary>Installing OpenJDK 8</summary>

To install OpenJDK 8 on macOS, follow the steps below:

1. Download the AdoptOpenJDK 8 from the [Adoptium](https://adoptium.net/) website.
2. Follow the [macOS PKG installer packages](https://adoptium.net/installation/macos/) instructions on the Adoptium website.
</details>

<details>
<summary>Installing Oracle Java 8</summary>


To install Oracle Java 8 (8u202), follow the steps below:

1. Download and run the Oracle JDK 8 (8u202) installer from the Oracle website.

   **❗ IMPORTANT**\
   Versions of the Oracle JDK 8 greater than update 202 (8u202) require a licence for commercial use. For more information, see the [Oracle Java SE Licensing FAQ](https://www.oracle.com/uk/java/technologies/javase/jdk-faqs.html) on the Oracle website.
2. Update your `~/.bash_profile` file with the following line:

   ```bash
   export JAVA_HOME=$(/usr/libexec/java_home)
   ```

   By default, the `/usr/libexec/java_home` program returns the path to the most recently installed JDK. To return the path to a specific version of Java, use the `-v` option. For example, to return the path to the latest version of Java 8, use the line below:

   ```bash
   export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
   ```
3. Log off and log back in to your account.

   The `~/.bash_profile` file is only run on login.

For more information on installing Oracle Java on macOS, see [Information and system requirements for installing and using Oracle Java on Mac OS X](https://www.java.com/en/download/help/java_mac.html).

On starting a Caplin application, you may see one or both of the errors below:

* "No Java runtime present, requesting install"
* "To open this Java application you need to install the legacy Java SE 6 runtime"

These errors appear to be caused by an issue with the default installation of Oracle Java 8 on macOS, which does not declare all of Java 8’s capabilities in Java 8’s macOS application metadata file `Info.plist`.

</details>
