I am trying to use java alternatives
to downgrade to java 1.6
from 1.8
. However despite this being set correctly in alternatives via --set
the java version still returns 1.8
:
Selection Command
-----------------------------------------------
*+ 1 /usr/java/jre1.6.0_37/bin/java
2 /usr/java/jre1.8.0_66/bin/java
java -version
java version "1.8.0_66"
A closer look then reveals that /usr/bin/java
will always point to the latest version because of:
ls -la /usr/bin/java
lrwxrwxrwx 1 root root 26 Mar 31 11:27 /usr/bin/java -> /usr/java/default/bin/java
ls -la /usr/java/
total 20
drwxr-xr-x 4 root root 4096 Mar 31 11:30 .
drwxr-xr-x 16 root root 4096 Oct 7 11:41 ..
lrwxrwxrwx 1 root root 16 Mar 31 11:27 default -> /usr/java/latest
drwxr-xr-x 7 root root 4096 Mar 31 11:27 jre1.6.0_37
drwxr-xr-x 7 root root 4096 Mar 31 11:30 jre1.8.0_66
lrwxrwxrwx 1 root root 21 Mar 31 11:30 latest -> /usr/java/jre1.8.0_66
I have experienced this on 2 separate RHEL 5.10/11 systems. Whilst trying to replicate this on CentOS I noticed that /usr/bin/java
links to /etc/alternatives/java
.
Back on my RHEL system looked at /etc/alternatives/java
:
ls -la /etc/alternatives/
total 24
drwxr-xr-x 2 root root 4096 Mar 31 12:02 .
drwxr-xr-x 78 root root 12288 Sep 25 2012 ..
lrwxrwxrwx 1 root root 30 Mar 31 12:02 java -> /usr/java/jre1.6.0_37/bin/java
As expected it links to the correct version which means /usr/bin/java
should link to /etc/alternatives/java
.
Why is this not the default behavior? Is it just a matter of changing the symlink to '/etc/alternatives/java' to manage downgrades?