下載官方的軟體包,參考地址:http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz?AuthParam=1511877655_2 ...
- 下載官方的軟體包,參考地址:http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz?AuthParam=1511877655_249331a15c5f013ed07d656d98e82d72其中後面的AuthParam參數為本次下載的即時參數,自己記得在下載的時候進行更改
wget http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz?AuthParam=1511877655_249331a15c5f013ed07d656d98e82d72
- 創建併進入/usr/local/java/文件夾,將軟體包進行解壓
tar -zxvf jdk-8u151-linux-x64.tar.gz
- 配置環境變數並使其生效
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
- 驗證環境安裝
java javac