I've two JDK's on my CentOS machine, 1.7 and 1.8.
When I set my JAVA_HOME
to 1.7 the java -version
command still shows 1.8
What's this? And how to fix?
I've two JDK's on my CentOS machine, 1.7 and 1.8.
When I set my JAVA_HOME
to 1.7 the java -version
command still shows 1.8
What's this? And how to fix?
It depends on how you run
java
. If you runjava -version
without specifying any path, the firstjava
executable found in$PATH
environment variable is used. This has nothing to do withJAVA_HOME
var.If you want to change the java executable you are using based on changing the
JAVA_HOME
var, you can run it:Did you also remember to change the location of the Java binaries in your path (environment)? You will still need to edit your
.bash_profile:
export JAVA_HOME=/usr/local/jdk1.7_92
or
/etc/environment:
JAVA_HOME=/usr/local/jdk1.7_92 export JAVA_HOME
(whichever way Centos supports setting the path at login) to point to the JDK (or JRE) you want to run.
Usually a java symbolic link is put under /usr/bin directory for java. You can see that by issuing "
which java
" command. You can try to change it if you have a root password, if you can't you may try to call java binary directly, like;IMO that should do the work.