Debian 6下安装JDK

在Debian(6及以下版本)的默认源中,并没有默认包含JDK,我们需要从non-free源中找到它。

1、设置源

确认你的apt源包含了non-free,类似如下的:

sudo vim /etc/apt/sources.list
deb http://debian.cn99.com/debian/ testing main contrib non-free
deb-src http://debian.cn99.com/debian/ testing main contrib non-free

2、安装

sudo apt-get install sun-java6-jdk

3、切换

Debian默认提供了软件的多种实现方式,比如java,就有sun-java-jdk、openjdk、gij等,默认好象已经安装了gij,我们切换成sun的jdk:

update-alternatives --config java
#出现下述选择“菜单”:
  Selection    Path                                  Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gij-4.4                       1044      auto mode
  1            /usr/bin/gij-4.4                       1044      manual mode
  2            /usr/lib/jvm/java-6-sun/jre/bin/java   63        manual mode
#我们当然选2啦~

现在再看看java -version
已经是:

java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)

成功!

Leave a Reply

Your email address will not be published. Required fields are marked *