欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Linux Centos6.8 安装配置JDK1.8

程序员文章站 2024-03-11 10:32:01
...
https://blog.csdn.net/qq_30436259/article/details/77414759

1:下载JDK  因为有Cookie认证 所以在JDK下载链接前需要加上

wget -c -P /root/Downloads --no-check-certificate --no-cookie --header "Cookie: s_nr=1420682671945; s_cc=true; oraclelicense=accept-securebackup-cookie; gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk7-downloads-1880260.html;s_sq=%5B%5BB%5D%5D"
一个完整的例子:
wget -c -P /root/Downloads --no-check-certificate --no-cookie --header "Cookie: s_nr=1420682671945; s_cc=true; oraclelicense=accept-securebackup-cookie; gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk7-downloads-1880260.html;s_sq=%5B%5BB%5D%5D" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz?AuthParam=1501553131_d3e0e6e1aee688dacca109570ef67f05

2:解压JDK

tar -xzvf jdk-8u144-linux-x64.tar.gz

3:配置环境变量

vim /etc/profile
最末加上:
  1. export JAVA_HOME=/usr/local/java/jdk/jdk1.8.0_144
  2. export PATH=$JAVA_HOME/bin:$PATH
  3. export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

4:修改的环境变量生效

source /etc/profile

5:验证

java -version