The installation of many Oracle software require the prior installation of a JDK. It’s not an issue and we saw how to install an Oracle JDK RPM package in a previous post. Unfortunately some products keep the JDK installation directory name in their settings or properties and it is not always easy to quickly modify this path everywhere. We are going to see in this page an easy solution to avoid this issue.

A JDK version 1.8.0_211+ was required to install the Oracle Fusion Middleware Infrastructure. I already had a more recent version of the JDK installed on my Oracle Linux 8.5 VM but it was not compatible with the “Oracle Fusion Middleware Infrastructure“ version I wanted to install. Therefore I downloaded an older version of the JDK and I installed it as before.


I now had two different versions of the JDK installed:

The current one was still version 1.18.0.1

So I used the command “sudo update-alternatives –config java” to change the “/etc/alternatives/java” to version “jdk-1.8.0_321“:

I renamed “jdk1.8.0_321-amd64” as “jdk” and I created a symbolic link from “jdk” to “jdk1.8.0_321-amd64“. In that way I could use the “/usr/java/jdk” directory as the JAVA_HOME during the installation and configuration of any RPM packages that require a valid JDK installation. Therefore the settings or parameters referencing the “/usr/java/jdk” directory wouldn’t have to be modified in case I had to change the JDK version in the future.

From now on, the procedure for updating the JDK version will then be as follows:
- Remove the existing symbolic link with the command “rm /usr/java/jdk1.8.0_321-amd64” (or the name of the existing version).
- Rename “/usr/java/jdk” to its original name with the version with the command “mv /usr/java/jdk /usr/java/jdk1.8.0_321-amd64” (for example).
- Install the new JDK with the command “sudo yum -y localinstall jdk-8uXYZ-linux-x64.rpm” (where XYZ is the new version).
- Run the command “sudo update-alternatives –config java” again to select the new JDK version.
- Rename the new version directory to “/usr/java/jdk” with command “mv /usr/java/jdk1.8.0_XYZ-amd64 /usr/ java/jdk” (for example)
- Create a new symbolic link from “/usr/java/jdk” to the new version as before with the command “ln -s /usr/java/jdk /usr/java /jdk1.8.0_XYZ-amd64” (for example).
And from now on, you will not have to modify the parameters that refer to the JDK installation directory because it will always be “/usr/java/jdk“.
Trust me, this can avoid a lot of painful settings/parameters modifications if you have many applications installed and configured.
Disclaimer
The post How to easily manage JDK installations on Oracle Linux appeared first on MyBIJourney