安装包:http://pan.baidu.com/s/1eSdR0Wi

/usr/local/java 把安装包上传到这里;

解压jdk:sudo tar xvf jdk1.7.0_79.tar

修改配置文件:vim .bash_profile

# .bash_profile


# Get the aliases and functions

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

# User specific environment and startup programs

#PATH=$PATH:$HOME/bin

export JAVA_HOME=/usr/local/java/jdk1.7.0_79

export JRE_HOME=/usr/local/java/jdk1.7.0_79/jre

export CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

source ~/.bash_profile

使得配置文件生效

java -version 查看是否安装成功

java version "1.7.0_79"

Java(TM) SE Runtime Environment (build 1.7.0_79-b15)

Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)