# Installing Java

The Caplin Platform requires the Oracle Java Development Kit (JDK) in order to run Java-based Caplin Platform Blades (CPB) and the JMX monitoring service. This page provides an overview of the steps required to install Oracle Java and set the `JAVA_HOME` environment variable on Microsoft Windows, Red Hat Enterprise Linux and Apple macOS.

 Always install an Oracle JDK compiled for the same architecture, 32-bit or 64-bit, as the Liberator and Transformer binaries in your deployment.

## Installing Java on Red Hat Enterprise Linux

Red Hat Linux supports the installation of multiple JDKs, and provides the `alternatives` command to select the active JDK. Follow the instructions below to install Oracle Java and set the `JAVA_HOME` environment variable.

1. Prepare the `alternatives` file-system links by installing the OpenJDK development package of the same major version as the Oracle JDK you want to install. For example, to prepare for the installation of Oracle JDK 8, install the OpenJDK 8.

`$sudo yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel` 2. From the Oracle website, download the RPM for the version of Oracle JDK that you require.  Caplin Platform binaries compiled for Linux require a 64-bit Oracle JDK. 3. Install the downloaded RPM. The example command below installs the RPM for the Oracle JDK 8 update 65 (64-bit). `$ sudo yum install jdk-8u65-linux-x64.rpm`
4. Run the two commands below to select the active Java installation. When prompted, select the Oracle JDK as the default installation.

`$sudo alternatives --config java` `$ sudo alternatives --config javac`
5. Add the following lines to your `~/.bash_profile` file:

`JAVAC_PATH=$(readlink -f /etc/alternatives/javac)` `export JAVA_HOME=${JAVAC_PATH%/bin/javac}`
 `/etc/alternatives/javac` is symlink that is updated by the command `alternatives --config javac`
6. Log off and log back in to your account.

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

## Installing Java on Microsoft Windows

To install Oracle Java and set the `JAVA_HOME` environment variable, follow the instructions below:

 Caplin Platform 6.2 binaries for Microsoft Windows require a 32-bit Oracle JDK. Caplin Platform 7 binaries for Microsoft Windows require a 64-bit Oracle JDK.
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.

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

## Installing Java on Apple macOS

Follow the instructions below to install Oracle Java and set the `JAVA_HOME` environment variable:

1. Download and run the Oracle JDK installer from the Oracle website.

2. Update your `~/.bash_profile` file with the following line:

`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: `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.

### Troubleshooting Java on macOS

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`).

For a solution to this error, see the links below: