tar xzvf jdk-7u51-linux-x64.gz -C /usr/local/java/; \
echo "export JAVA_HOME=/usr/local/java/jdk1.7.0_51" >> /etc/profile; \
echo "export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tool.jar:$JAVA_HOME/jre/lib/rt.jar:." >> /etc/profile; \
echo "export PATH=$JAVA_HOME/bin/:$PATH" >> /etc/profile; java -version
- 创建一个目录/usr/local/java;
- 下载最新的jdk安装包,http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html;
- 解压缩jdk安装包到/usr/local/java;
- 配置JAVA_HOME和CLASSPATH;
- 把常用可执行文件加入到PATH;
- 验证java版本;
关闭防火墙:
/etc/init.d/iptables stop 关闭防火墙。
chkconfig iptables off 关闭开机启动。