https://help.ubuntu.com/community/Java
sudo apt-get install openjdk-7-jdk
----------------------------------------------------------------------
http://www.oracle.com/technetwork/java/javase/downloads/index.html 选择自己需要的版本
官网提供两种JDK的下载
jdk-6u30-linux-i586-rpm.bin
jdk-6u30-linux-i586.bin
Ubuntu下要下载jdk-6u30-linux-i586.bin
$ sh jdk-6u30-linux-i586.bin
在当前路径下会生成一个文件夹
之后需要配置环境变量
~/.bashrc也可设置环境变量
$ sudo vim /etc/profile
#set java environment
JAVA_HOME=/usr/lib/jdk1.6.0_30
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/:$JAVA_HOME/jre/lib
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
$ source /etc/profile
$ java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) Client VM (build 20.5-b03, mixed mode, sharing)