Ubuntu:将路径从 OpenJDK 6 更改为 Oracle JDK 7
2022-09-02 02:23:22
下载最新的.tar文件后,我运行以提取java文件。tar zxvf jdk-7u45-linux-x64.tar.gz
在文件()中设置路径,如下所示;.bashrc
vi ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_45/bin/java
export PATH=$PATH:/usr/lib/jvm/jdk1.7.0_45/bin
export JDK_HOME=/usr/lib/jvm/jdk1.7.0_45
export JRE_HOME=/usr/lib/jvm/jre1.7.0_45
现在,运行命令或哪个java,java PATH仍然指向较旧的java版本()。java -version
java version "1.6.0_27"
我知道默认的ubuntu采用OpenJDK路径。我必须将路径更改为文件中设置的系统环境变量的最新版本。.bashrc
也sudo update-alternatives --config java
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 manual mode
* 3 /usr/lib/jvm/jdk1.7.0_45/bin/java 1 manual mode
Press enter to keep the current choice[*], or type selection number: 3