1.去镜像网站下载jdk(这里是去华为云下载的)
cd /usr/local wget https://repo.huaweicloud.com/java/jdk/9.0.1+11/jdk-9.0.1_linux-x64_bin.tar.gz
2. 解压
tar -zxvf tar -zxvf jdk-9.0.1_linux-x64_bin.tar.gz
3.配置JAVA_HOME:
vi /etc/profile
内容如下:
export JAVA_HOME=/usr/local/jdk-9.0.1 export JRE_HOME=/usr/local/jdk-9.0.1/jre export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
4.使修改生效:
source /etc/profile
5.验证是否安装成功:
java -version
成功!