3

I am using Cent-OS.

When I execute "java -version", it displays: java version "1.7.0_45"

When i execute "echo $JAVA_HOME", it displays /usr/java/jdk1.8.0_51

I set JAVA_HOME in ~/.bashrc and sourced it. I also tried setting in /etc/profile and sourced it as well. In profiles, I am setting java home as:

JAVA_HOME=/usr/java/jdk1.8.0_51

export PATH=$PATH:$JAVA_HOME/bin

Please tell me how to set java version to 1.8 only.

1
  • put $JAVA_HOME/bin in front of the path as follows, export PATH=$JAVA_HOME/bin:$PATH Commented Aug 15, 2015 at 15:07

1 Answer 1

10

I believe 1.7.0_45 is set in your path already, and in order to use 1.8.0_51, export the path as follows,

export PATH=$JAVA_HOME/bin:$PATH 

This will add new JAVA path in front of the existing java path. The issue in your export is the new java path is added after the existing path. Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.