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

前端 未结 10 1442
温柔的废话
温柔的废话 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 01:59

    update-java-alternatives

    The java executable is not found with your JAVA_HOME, it only depends on your PATH.

    update-java-alternatives is a good way to manage it for the entire system is through:

    update-java-alternatives -l
    

    Sample output:

    java-7-oracle 1 /usr/lib/jvm/java-7-oracle
    java-8-oracle 2 /usr/lib/jvm/java-8-oracle
    

    Choose one of the alternatives:

    sudo update-java-alternatives -s java-7-oracle
    

    Like update-alternatives, it works through symlink management. The advantage is that is manages symlinks to all the Java utilities at once: javac, java, javap, etc.

    I am yet to see a JAVA_HOME effect on the JDK. So far, I have only seen it used in third-party tools, e.g. Maven.

提交回复
热议问题