我刚安装了最新的java /usr/jdk/jdk1.6.0_30
现在如何让这个java是整个OS的默认java? 截至目前它仍然使用Java 1.5
谢谢。
find了…
$which java /usr/bin/java $ls -ld /usr/bin/java lrwxrwxrwx 1 root other 16 Apr 8 12:41 /usr/bin/java -> ../java/bin/java $rm /usr/bin/java $ln -s /usr/jdk/jdk1.6.0_27/bin/java /usr/bin/java $java -version java version "1.6.0_27" Java(TM) SE Runtime Environment (build 1.6.0_27-b07) Java HotSpot(TM) Server VM (build 20.2-b06, mixed mode)
我觉得只要更改/usr/bin/java
的符号链接是不够的,因为/usr/bin/java
有多个Java符号链接:
# ls -l /usr/bin/java* lrwxrwxrwx 1 root other 16 May 21 2015 /usr/bin/java -> ../java/bin/java lrwxrwxrwx 1 root other 17 May 21 2015 /usr/bin/javac -> ../java/bin/javac lrwxrwxrwx 1 root other 19 May 21 2015 /usr/bin/javadoc -> ../java/bin/javadoc lrwxrwxrwx 1 root other 17 May 21 2015 /usr/bin/javah -> ../java/bin/javah lrwxrwxrwx 1 root other 17 May 21 2015 /usr/bin/javap -> ../java/bin/javap lrwxrwxrwx 1 root other 18 Jul 21 2015 /usr/bin/javaws -> ../java/bin/javaws
相反,我会利用这个事实,即/usr/java
本身就是一个符号链接,而不是其他6个符号链接。 以下是我如何使JDK 8成为默认值:
# cd /usr # rm java # ln -s jdk/jdk1.8.0_121 java # java -version java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13)