Debian Lenny下的JDK安装与配置

以前用过一段时间的ubuntu,写过一个使用alternatives配置多个JDK的方法(http://arthurln.iteye.com/admin/blogs/76379),最近开始用debian了,虽然都是debian内核,安装和配置上还是有一些不同。

1、添加non-free源

# gedit /etc/apt/sources.list

下边是我的配置,仅作参考

deb http://ftp.us.debian.org/debian/ lenny main contrib non-free
deb-src http://ftp.us.debian.org/debian/ lenny main contrib non-free

deb http://security.debian.org/ lenny/updates main
deb-src http://security.debian.org/ lenny/updates main

deb http://volatile.debian.org/debian-volatile lenny/volatile main
deb-src http://volatile.debian.org/debian-volatile lenny/volatile main

deb http://www.backports.org/debian lenny-backports main contrib non-free
deb-src http://www.backports.org/debian lenny-backports main contrib non-free

更新软件列表

# aptitude install debian-backports-keyring
# aptitude update

2、下载并安装jdk

# aptitude install sun-java6-jdk

3、替换系统中现存的java环境

# update-java-alternatives -s java-6-sun

4、添加环境变量(跟其他系统下一样,这是可选的)

# gedit /etc/environment

添加

JAVA_HOME=/usr/lib/jvm/java-6-sun/
JRE_HOME=/usr/lib/jvm/java-6-sun/jre
CLASSPATH=.:/usr/lib/jvm/java-6-sun/lib/dt.jar:/usr/lib/jvm/java-6-sun/lib/tools.jar

5、使环境变量生效

source /etc/environment

相关推荐