- 下载官方的软件包,参考地址:http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz?AuthParam=1511877655_249331a15c5f013ed07d656d98e82d72其中后面的AuthParam参数为本次下载的即时参数,自己记得在下载的时候进行更改
1wget http:
//download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz?AuthParam=1511877655_249331a15c5f013ed07d656d98e82d72
- 创建并进入/usr/local/java/文件夹,将软件包进行解压
1
tar -zxvf jdk-8u151-linux-x64.tar.gz
- 配置环境变量并使其生效
12345
vi /etc/profile
#在该文件中导入环境变量,其中HOME为jdk解压根目录
export JAVA_HOME=/usr/local/java/jdk1.8.0_151
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
- 验证环境安装
12
java
javac
每天进步一点点,十年后我就和室友当年一样强!