I recently tried installing the most recent version of Oracle JDK (1.8) but somehow I'm unable to overwrite the current version of java being used by the system. I set the JAVA_HOME variable to point to the new installation, added it to the path and exported the variables, as shown below:
Contents of /etc/profile:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
JAVA_HOME=/usr/local/java/jdk1.8.0_40
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME
export PATH
~
Output of environment variables:
echo $JAVA_HOME
/usr/local/java/jdk1.8.0_40
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/java/jdk1.8.0_40/bin
But here's the issue:
java -version
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
which java
/usr/bin/java
javac -version
javac 1.7.0_72
'java -version' and javac are still pointing to the original installation. I installed gradle (for which I made the upgrade in the first place), which points to the newer installation.
gradle --version
------------------------------------------------------------
Gradle 1.5
------------------------------------------------------------
Gradle build time: Sunday, June 15, 2014 3:27:36 PM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.4 compiled on May 9 2014
Ivy: non official version
JVM: 1.8.0_40 (Oracle Corporation 25.40-b25)
OS: Linux 3.16.0-31-generic amd64
Additional references:
update-alternatives --display java
java - auto mode
link currently points to /usr/lib/jvm/java-7-oracle/jre/bin/java
/usr/lib/jvm/java-7-oracle/jre/bin/java - priority 2
slave java.1.gz: /usr/lib/jvm/java-7-oracle/man/man1/java.1.gz
Current 'best' version is '/usr/lib/jvm/java-7-oracle/jre/bin/java'.
update-alternatives --display javac
javac - auto mode
link currently points to /usr/lib/jvm/java-7-oracle/bin/javac
/usr/lib/jvm/java-7-oracle/bin/javac - priority 2
slave javac.1.gz: /usr/lib/jvm/java-7-oracle/man/man1/javac.1.gz
Current 'best' version is '/usr/lib/jvm/java-7-oracle/bin/javac'.
How do I fix this mess? Any help would be most appreciated! Also, if I need to remove the earlier v1.7, how do I do this?
update-alternatives --display java
andupdate-alternatives --display javac
?sudo update-alternatives --install /usr/bin/java java /usr/local/java/jdk1.8.0_40/bin/java 100 && sudo update-alternatives --install /usr/bin/javac javac /usr/local/java/jdk1.8.0_40/bin/javac 100
....then check..(note: use@
infront of my name to tag me in the comment, otherwise i won't get any notification)