linux 常用命令(五)——(centos7-centos6.8)JDK安裝,

來源:互聯網
上載者:User

linux 常用命令(五)——(centos7-centos6.8)JDK安裝,

1.安裝jdk前先檢測系統是否帶有OpenJDK:若存在則刪除

  查看: java -version 

  查詢出OpenJDK相關的檔案:rpm -qa | grep java

  刪除OpenJDK相關的檔案:rpm -e --nodeps 相關檔案

2.上傳要安裝的jdk安裝包至安裝目錄:/mnt/soft/java【安裝目錄自訂】

  解壓安裝包: tar -xzvf  jdk安裝包 

  移動解壓後的檔案至java檔案夾  : mv 解壓後的檔案夾 java

3.配置環境變數:

  編輯/etc/profile 添加配置內容:

    vim /etc/profie :在檔案末尾追加如下內容

export JAVA_HOME=/mnt/soft/java/
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

4.執行profile檔案:

  使用點命令或source命令執行: . /etc/profile  or  source /etc/profile

5.查看安裝的jdk:

  java -version

  顯示: 

java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

安裝結束。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.