Centos comes with openjdk. When installing eclipse, download the latest jdk. Extract it to the /usr/java directory.
tar zxvf jre-8u121-linux-x64.tar.gz
Set environment variables
#vi /etc/profile
export JAVA_HOME="/usr/java/jdk1.8.0_121"
export CLASS_PATH=".:/usr/java/jdk1.8.0_121/lib/dt.jar:/usr/java/jdk1.8.0_121/lib/tools.jar"
export PATH="$PATH:/usr/java/jdk1.8.0_121/bin"
#source /etc/profile
Now you can see the results of the registration:
03 |
There are 3 programs which provide 'java' . |
06 |
----------------------------------------------- |
07 |
*+ 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java |
08 |
2 /usr/java/jre1.6.0_21/bin/java |
09 |
3 /usr/java/jdk1.6.0_21/bin/java |
11 |
Enter to keep the current selection[+], or type selection number: |
Just enter the java you want to use here, for example, I chose the second one. Let's look at the changes in /usr/bin/java:
2 |
lrwxrwxrwx 1 root root 22 Dec 17 2009 /usr/bin/java -> /etc/alternatives/java |
4 |
lrwxrwxrwx 1 root root 30 Aug 23 15:03 /etc/alternatives/java -> /usr/java/jre |