2021-05-12 14:32:11
Ubuntu 14.04 LTS下安裝JDK 1.8
Ubuntu 14.04 LTS下安裝JDK 1.8
先到Oracle官網的下載中心下載JDK8的tar包到本地。
下載地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
建立應用程式主目錄
linuxidc@ubuntu:/usr/lib$ sudo mkdir jvm
解壓下載的tar包到應用程式主目錄下
linuxidc@ubuntu:~/Downloads$ sudo tar zxf jdk-8u65-linux-x64.tar.gz -C /usr/lib/jvm
重新命名下資料夾
linuxidc@ubuntu:/usr/lib/jvm$ sudo mv jdk1.8.0_65 java
安裝vim(因為UBuntu預設情況下不安裝vim命令,需要用apt-get命令安裝)
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
vim-runtime
Suggested packages:
ctags vim-doc vim-scripts
The following NEW packages will be installed:
vim vim-runtime
0 upgraded, 2 newly installed, 0 to remove and 6 not upgraded.
Need to get 5,844 kB of archives.
After this operation, 28.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main vim-runtime all 2:7.4.052-1ubuntu3 [4,888 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main vim amd64 2:7.4.052-1ubuntu3 [956 kB]
Fetched 5,844 kB in 18min 52s (5,159 B/s)
設定環境變數,vim ~/.bashrc檔案
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo vim ~/.bashrc
新增下面的內容到檔案尾部
export JAVA_HOME=/usr/lib/jvm/java
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
如果你的Ubuntu上已經安裝了其他版本的JDK,你可以通過update-alternatives命令來設定比如命令Java的預設命令路徑。然後就是編譯下讓update-alternatives設定生效。
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java/bin/java 300
update-alternatives: using /usr/lib/jvm/java/bin/java to provide /usr/bin/java (java) in auto mode
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java/bin/javac 300
update-alternatives: using /usr/lib/jvm/java/bin/javac to provide /usr/bin/javac (javac) in auto mode
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/java/bin/jar 300
update-alternatives: using /usr/lib/jvm/java/bin/jar to provide /usr/bin/jar (jar) in auto mode
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/java/bin/javah 300
update-alternatives: using /usr/lib/jvm/java/bin/javah to provide /usr/bin/javah (javah) in auto mode
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/java/bin/javap 300
update-alternatives: using /usr/lib/jvm/java/bin/javap to provide /usr/bin/javap (javap) in auto mode
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java/bin/java
Nothing to configure.
最後檢查是否安裝成功
linuxidc@ubuntu:/usr/lib/jvm/java$ java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
linuxidc@ubuntu:/usr/lib/jvm/java$
Ubuntu 14.04安裝JDK1.8.0_25與設定環境變數 http://www.linuxidc.com/Linux/2015-01/112030.htm
CentOS 搭建JDK環境 http://www.linuxidc.com/Linux/2015-06/118879.htm
Ubuntu 14.04安裝JDK1.8.0_25與設定環境變數 http://www.linuxidc.com/Linux/2015-01/112030.htm
Ubuntu 14.04 LTS安裝Oracle JDK 1.8 http://www.linuxidc.com/Linux/2014-11/109216.htm
CentOS6.3安裝JDK和環境設定 http://www.linuxidc.com/Linux/2012-09/70780.htm
Ubuntu 14.04 安裝 JDK8 http://www.linuxidc.com/Linux/2014-09/106218.htm
Ubuntu下安裝JDK圖文解析 http://www.linuxidc.com/Linux/2014-09/107291.htm
相關文章