centos安装jdk

# 安装jdk
mkdir /opt/java
cd /opt/java
# 去Java官网下载jdk

tar zxvf jdk-8u51-linux-x64.tar.gz

# 设置环境变量

echo "export JAVA_HOME=/opt/java/jdk1.8.0_51" >> /etc/profile
echo "export JRE_HOME=\$JAVA_HOME/jre" >> /etc/profile
echo "export CLASSPATH=:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar:\$JRE_HOME/lib" >> /etc/profile
echo "export PATH=\$PATH:\$JAVA_HOME/bin:\$JRE_HOME/bin" >> /etc/profile
source /etc/profile

java -version

 

posted @ 2018-03-15 09:33  alsoalso  阅读(108)  评论(0编辑  收藏  举报