JAVA_HOME and PATH are set but java -version still shows the old one

前端 未结 10 1413
温柔的废话
温柔的废话 2020-11-29 01:12

I am using Linux Mint Cinnamon 14. I have set the $JAVA_HOME and $PATH environment variables in ~/.profile as follows:



        
10条回答
  •  眼角桃花
    2020-11-29 02:00

    When it searches for java it looks from left to right in path entries which are separated by : so you need to add the path of latest jdk/bin directory before /usr/bin, so when it searches it'll find the latest one and stop searching further.

    i.e. PATH=/usr/java/jdk_1.8/bin:/usr/bin:..... and so on.

    then initialize user profile using command: source ~/.bash_profile

    and check with: [which java]

    you'll get the right one.

提交回复
热议问题