因Oracle JDK許可更改,該Shell腳本於2020年2月16日(週日)停止維護。- 2012年12月26日
You need to login in to download JDK 8, JDK 11. This script still supports JDK12, JDK 13 download. (Stop maintaining this script on Feb 16, 2020 Sun.)
Java SE
是Java Platform, Standard Edition
的縮寫,而JDK
是Java SE Development Kit
的縮寫,JDK爲Java應用提供環境支持。本文記錄如何在GNU/Linux中安裝、配置 Oracle JDK,並通過Shell腳本實現整個過程。
Oracle JDK許可已於April 16, 2019
更新,詳見 Oracle Technology Network License Agreement for Oracle Java SE。
Oracle JDK License
從2019年1月起,Oracle將不再對普通用戶(非商用)提供 Java SE 8 的更新支持。
Important Oracle JDK License Update
The Oracle JDK License has changed for releases starting April 16, 2019.
The new Oracle Technology Network License Agreement for Oracle Java SE is substantially different from prior Oracle JDK licenses. The new license permits certain uses, such as personal use and development use, at no cost – but other uses authorized under prior Oracle JDK licenses may no longer be available. Please review the terms carefully before downloading and using this product. An FAQ is available here.
Commercial license and support is available with a low cost Java SE Subscription.
Oracle also provides the latest OpenJDK release under the open source GPL License at jdk.java.net.
Oracle JDK 12
Oracle JDK 11
Oracle JDK 8
Oracle Java SE License
Oracle Technology Network License Agreement for Oracle Java SE
Shell Script
整個安裝、配置過程已通過Shell腳本實現,代碼託管在GitLab,通過如下命令執行
|
|
支持週期
Oracle對各JDK版本的支持週期,詳見官方文檔 Oracle Java SE Support Roadmap
Java SE 公共更新
Release | GA Date | End of Public Updates Notification | End of Public Updates |
---|---|---|---|
8 | Mar 2014 | Sep 2017 | January 2019 and December 2020 |
9 | Sep 2017 | Sep 2017 | Mar 2018 |
10 (18.3) | Mar 2018 | Mar 2018 | Sep 2018 |
11(18.9 LTS) | Sep 2018 |
Java SE 支持路線圖
Release | GA Date | Premier Support Until | Extended Support Until | Sustaining Support |
---|---|---|---|---|
6 | Dec 2006 | Dec 2015 | Dec 2018 | Indefinite |
7 | Jul 2011 | Jul 2019 | Jul 2022 | Indefinite |
8 | Mar 2014 | Mar 2022 | Mar 2025 | Indefinite |
9 (non-LTS) | Sep 2017 | Mar 2018 | Not Available | Indefinite |
10 (18.3^) (non-LTS) | Mar 2018 | Sep 2018 | Not Available | Indefinite |
11 (18.9 LTS) | Sep 2018 | Sep 2023 | Sep 2026 | Indefinite |
12 (19.3^ non‑LTS) | March 2019 | September 2019 | Not Available | Indefinite |
下載
JDK官方下載頁 Java SE Downloads
Oracle對下載做了設置,必須得同意其許可 Oracle Binary Code License Agreement for Java SE 才能下載。勾選Accept License Agreement
後,會出現如下信息
Thank you for accepting the Oracle Binary Code License Agreement for Java SE; you may now download this software.
這爲通過命令行或Shell腳本下載設置了障礙。參考
Oracle在cookie中設置了指令oraclelicense
,通過它判斷用戶是否已同意其許可協議,完整參數爲oraclelicense=accept-securebackup-cookie
。
可通過如下命令實現非交互操作
|
|
安裝
安裝包後綴.tar.gz
,可通過如下命令解壓並安裝到目標目錄
|
|
配置
解壓後,文件目錄信息如下
|
|
$PATH
可執行文件存放在bin/
目錄中,須將該路徑添加到環境變量$PATH
中。
個人建議將配置信息存放在目錄/etc/profile.d/
中,此處假設文件名爲oracle_se_jdk.sh
|
|
Aalternatives
如果系統安裝有多個版本的JDK,可通過alternatives
或update-alternatives
爲java
設置默認的可執行路徑。
代碼實現
|
|
測試
演示示例
|
|
引用
更新日誌
- 2018.04.19 16:48 Wed America/Boston
- 初稿完成
- 2018.05.14 09:08 Mon America/Boston
- 添加 reference
- 2018.11.29 10:28 Thu America/Boston
- 更新釋出版本
- 2019.04.06 11:32 Sat America/Boston
- 更新釋出版本至
v12
- 更新釋出版本至
- 2019.04.26 15:30 Fri America/Boston
- Oracle 更新 JDK 許可
- 2020.12.26 20:55 Sat America/Boston
- 本文和Shell腳本停止維護