Ubuntu 16.04安裝Java 8
阿新 • • 發佈:2019-05-21
1 Java 8 下載地址
http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html
2 以root使用者登入將下載的jdk-8u92-linux-x64.tar.gz檔案放到/temp目錄下,使用如下命令解壓
tar zxvf jdk-8u92-linux-x64.tar.gz
3 將解壓後的jdk1.8.0_92複製到/opt下,命令如下:
root@test:~# mkdir /temp
root@test:~# cd /temp
root@test:/temp# tar zxvf jdk-8u92-linux-x64.tar.gz
root@test:/temp# cd /opt
root@test:/opt# mv /temp/jdk1.8.0_92/ .
root@test:/opt# ls -l
總用量 4
drwxr-xr-x 8 uucp 143 4096 4月 1 12:20 jdk1.8.0_92
4 在/bin目錄下建立java軟連結
root@test:/opt# cd /bin
root@test:/bin# ln -s /opt/jdk1.8.0_92/bin/java java
驗證軟體接的正確性
root@test:/bin# java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
5 設定Java環境
root@test:/bin# gedit /etc/profile export JAVA_HOME=/opt/jdk1.8.0_92 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH root@test:/bin# source /etc/profile root@test:/bin# echo $JAVA_HOME /opt/java1.8.0_92
6 切換到其它使用者驗證
ccskun@test:~$ echo $JAVA_HOME /opt/jdk1.8.0_92 ccskun@test:~$ java -version java version "1.8.0_92" Java(TM) SE Runtime Environment (build 1.8.0_92-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)