1. 首先下载jdk-6u45-linux-x64.bin, 如果是32bit系统下载相应的i386即可.
  2. 更改文件权限-> chmod a+x jdk-6u45-linux-x64.bin.
  3. 创建目录sudo mkdir /usr/lib/jvm/
  4. 将该文件拷贝到相应的目录下(/usr/lib/jvm).
  5. 进入该目录,执行sudo ./jdk-6u45-linux-x64.bin, 等待其解压完成.
  6. 设置链接sudo ln -s -b /usr/lib/jvm/jdk1.6.0_45/jre/bin/java /etc/alternatives/java sudo ln -s -b /usr/lib/jvm/jdk1.6.0_45/jre/bin/java /usr/bin/java
  7. 检测是否成功java -version

      转自:http://blog.segmentfault.com/zhouquan/1190000000491775