2

I am new to ubuntu. I am trying to use java-8. Where I have already installed java-6 in my ubuntu machine. I just want to use java-8 from my terminal (for test purpose); not from all over my machine. I want java-6 remains for all other software like eclipse. I heard to to so we can ubuntu terminal to export. So I am trying to do this -

$ export JAVA_HOME=/usr/lib/jvm/jdk8
$ export PATH=$PATH:$JAVA_HOME

after doing this when I type in terminal the fllowing command -

$ java -version 

it gives -

java version "1.6.0_29" Java(TM) SE Runtime Environment (build 1.6.0_29-b11) Java HotSpot(TM) Server VM (build 20.4-b02, mixed mode)

I tried several ways but nothing is working for me.

1 Answer 1

6

I think you are missing the bin directory name after the $JAVA_HOME. Try this -

 $ export JAVA_HOME=/usr/lib/jvm/jdk8
 $ export PATH=$JAVA_HOME/bin:$PATH  

Note: I have place the JAVA_HOME before PATH. That means the JAVA_HOME/bin is concatenated with the existing PATH where the JAVA_HOME/bin is placed at the beginning of the new PATH. If you place the JAVA_HOME/bin at the end of the current PATH then the JAVA_HOME/bin is concatenated at the end of the new PATH. In this case the older JAVA_HOME (if exist one, in your case the jdk-6) may found first at the new PATH variable and will get precedence. A lots of times I get wrong when I placed JAVA_HOME/bin at the end of the PATH. So add JAVA_HOME/bin at the beginning in this case.

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.