ubuntu11.04更改默认JDK

Ubuntu11.04自带有默认的OpenJDK,虽然网上很多文章说OpenJDK和Sun的JDK没什么区别,但以防万一,还是用官方的吧。


第一步,安装Sun的JDK:

sudo apt-get install sun-java6-jre

sudo apt-get install sun-java6-jdk

此时,在命令行里面输入java -version,显示的JDK仍然是OpenJDK,所以需要修改默认的JDK


第二步,修改默认JDK

sudo update-alternatives --config java

此时,命令行中会提示你选择合适的JDK,如

There are 2 choices for the alternative java (providing /usr/bin/java).


Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode


Press enter to keep the current choice[*], or type selection number: 2


选择java-6-sun后,再输入java -version,就会显示Sun的JDK信息了


你可能感兴趣的:(ubuntu)