To see which version(s) of JDKs are installed, run the below command:
update-java-alternatives --list
Use java -version , to see which Java version you are currently using.
To use the latest OpenJDK 8, follow the following steps to install and set OpenJDK 8 the default Java version:
Enter the following command, type user password and hit Enter to continue.
sudo add-apt-repository ppa:openjdk-r/ppa
Update system package cache with the command :
sudo apt-get update
Install OpenJDK 8 by running :
sudo apt-get install openjdk-8-jdk
To make it the default version, enter :
sudo update-alternatives --config java
and select OpenJDK 8 by typing the selection number against it.
Also, set default Java Compiler by running :
sudo update-alternatives --config javac
Now run
java -version
to check if Java is updated.
Reference:
http://ubuntuhandbook.org/index.php/2015/01/install-openjdk-8-ubuntu-14-04-12-04-lts/
$PATHvariable. I am not sure how CentOS manages environment variables and software alternatives, but you might want to look into this topic. Maybe this helps.