转自:http://my.oschina.net/ckanner/blog/103300
安装了ubuntu12.10,折腾了一下,终于将JDK6安装成功了。以此记录一下。
1. 去官网下载JDK6,我下载后的保存路径为/home/kanner/下载/jdk-6u38-linux-i586.bin
2.在/usr/lib新建java目录:sudo mkdir /usr/lib/java
3.复制文件到该新建目录:sudo cp /home/kanner/下载/jdk-6u38-linux-i586.bin /usr/lib/java
4.赋予该文件以可运行的权限:sudo chmod u+x jdk-6u38-linux-i586.bin
5.运行该文件:sudo ./jdk-6u38-linux-i586.bin
6.配置环境变量:sudo vi /etc/profile,在文件末尾添加环境变量:
export JAVA_HOME=/usr/lib/java/jdk1.6.0_38
export JRE_HOME=/usr/lib/java/jdk1.6.0_38
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
7.令修改后的文件立即生效:. /etc/profile
8.修改系统默认jdk,并立即生效:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/java/jdk1.6.0_38/bin/java" 300
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/java/jdk1.6.0_38/bin/javac" 300
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/java/jdk1.6.0_38/bin/javaws" 300
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws
9.至此,jdk6安装成功。在终端下用命令java -version查看效果,如下,即表示安装成功:
java version "1.6.0_38"
Java(TM) SE Runtime Environment (build 1.6.0_38-b05)
Java HotSpot(TM) Server VM (build 20.13-b02, mixed mode)