我使用centos7X64最小化安装
CentOS-7-x86_64-Minimal-1708
1.安装wget
2.下载jdk8
1
| wget http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz?AuthParam=1515389081_199e6be1d23489a50e55e6979e5f31c9
|
若失效,官网自己查下载地址
3.解压
1
| tar -zxvf jdk-8u151-linux-x64.tar.gz?AuthParam=1515389081_199e6be1d23489a50e55e6979e5f31c9
|
4.移动到/usr/local/java/jdk1.8.0_151
1
| mkdir -p /usr/local/java
|
1
| mv jdk1.8.0_151/ /usr/local/java/jdk1.8.0_151
|
5.设置环境变量
文件最后加入:
1 2 3
| export JAVA_HOME=/usr/local/java/jdk1.8.0_151 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
|
6.配置文件立即生效
7.查看是否安装成功