You’re probably looking for information on how to install multiple versions of Java on Linux as part of a migration piece of work and/or a new deployment activity after spinning up a new Linux server which has a different version of Java running than what your Java web application was compiled in. Whatever Java version your application is compiled in needs to be the same Java version that is running on your web application server to ensure it works without issues (or even just works!).
So, let’s assume you’ve got the handy yum tool installed on your Linux box which allows you to easily run handy commands to install software. Within yum you can find lots of handy versions of java just sitting around waiting to install them. Take a look at all the Java packages within yum.
What you’ll notice is that the majority of them are utilising the OpenJDK setup. This is a handy open source version of the Java platform. So all you need to do is get it installed then get it configured. Simple.
Check Current Java Version Installed
Firstly you need to check the current version of Java that you have installed on your Linux box. To do this simply run the following command;
Install Java 1.8 Version on Linux Using Yum
Simply run the following command to install the latest version of Java (whatever the latest version is on your system);
sudo yum instal java-1.8.0-openjdk
Configure Linux to Use the New Version of Java via Alternatives
On Linux machines you can configure multiple versions of Java to run via the ‘alternatives’ feature. This essentially allows you to install multiple Java versions alongside each other without having to worry about the specifics. This allows you to have multiple versions of Java installed, and still configure a default.
Which basically means that when you run any default java command that it will run against whatever alternative has been configured to point at the different versions of Java installed on your Linux box.
To check this, simply run the command;
sudo alternatives --config java
Which will allow you to configure which is the default Java version.
And it’s as simple as that. Install as many versions of Java as you need, but you can only use one of them at once.
If you have multiple applications running which all require different versions of Java then you have a couple of options. Either upgrade everything so they are all running the latest version of Java so you can keep everything on a single server. Or move applications to their own servers to give yourself the maximum control.
Latest posts by Michael Cropper (see all)
- How to Transfer WHM cPanel from One Server to Another Server - November 20, 2020
- How to Upgrade XenServer to XCP-NG Server - November 6, 2020
- Understanding the Differences in Managed VS Unmanaged Web Hosting - October 1, 2020