Why java -version returning a different version than the one defined in JAVA_HOME?
Posted
by
Shekhar
on Super User
See other posts from Super User
or by Shekhar
Published on 2012-09-29T08:07:48Z
Indexed on
2012/09/29
9:40 UTC
Read the original article
Hit count: 295
I am trying to set JAVA_HOME
in Ubuntu OS. I have copied jdk 1.7
in /usr/lib/jvm
and set JAVA_HOME
in /etc/profile
file.
Contents of /usr/lib/jvm
folder are as follows :
shekhar@ubuntu:~$ ls /usr/lib/jvm/
default-java java-1.6.0-openjdk java-6-openjdk java-6-openjdk-i386 jdk1.7.0_01
java-1.5.0-gcj-4.6 java-1.6.0-openjdk-i386 java-6-openjdk-common java-7-openjdk-i386
and last few lines of /etc/profile
file are as follows :
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_01
export PATH=$PATH:$JAVA_HOME/bin
After finishing all this when I run java -version
command I get following output :
shekhar@ubuntu:~$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.4) (6b24-1.11.4-1ubuntu0.12.04.1)
OpenJDK Server VM (build 20.0-b12, mixed mode)
and when I run ls -lah
command I get following output :
shekhar@ubuntu:~$ ls -lah /usr/bin/java
lrwxrwxrwx 1 root root 22 Sep 29 09:58 /usr/bin/java -> /etc/alternatives/java
shekhar@ubuntu:~$ ls -lah /etc/alternatives/java
lrwxrwxrwx 1 root root 45 Sep 29 09:58 /etc/alternatives/java -> /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java
Can anyone please tell me which thing I am missing? Why Ubuntu is still pointing to open jdk and not to my jdk 7?
PS : I have seen this similar question and its answers but that question is related to Windows OS and not for Ubuntu so I am reposting this similar question for Ubuntu.
© Super User or respective owner