Install multiple versions of Java
Because of software-specific requirements, installation of multiple versions of JVM is therefore needed. For example, you have a 64-bit OS server with JVM installed. You now want to run a 32-bit Java-based application while the existing JVM utilities do not support. Before making your server 32-bit compatible, you need to install the 32-bit version of JVM. In this tutorial, I will show step by step how to install a JVM version on Linux server.
List of existing Java versions You may want to take a look at existing Java versions installed on your server. The following command will list them in priority order, and also indicates the one that is selected by default.
update-alternatives --display java
# To remove any of those listed,
rpm -e java-1.5.0-gcj --nodeps
Installation procedure First, choose the Java install package at Oracle website. Assume the chosen one is "jre-7u3-linux-i586.tar.gz", then just download the package to your server. Let the package be placed in /usr/lib/jvm. Change to the folder and run the command to install the download package:
tar –xvf jre-7u3-linux-i586.tar.gz # this command extract the package
# into "jre1.7.0_03" folder. Please
# note that the folder name differs
# from package to package
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0_03/bin/java 10
Update the alternatives link for Java Please make sure that the default JVM version is still 64 bit. This can be checked by looking at the link currently points to string in the output of the "List of existing Java versions" command. If the default Java version is 32 bit, then change it to 64 bit, by using the command:
sudo update-alternatives --config java
Java shared librariesJava based linraries sometimes are placed in folders different from the default ones, making library loading problem to the applied applications. The issue can be resolved by indicating the folder path in Java config file. Followings show how to make it;
vi /etc/ld.so.conf.d/java.conf
# add the following lines, make modification based on your java version
/usr/lib/jvm/java-8-oracle/jre/lib/amd64
/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server
# save the file content and reload system config
ldconfig