以前、Ubuntu 20にOpenJDKをインストールしました。
今回はOracle JAVA 17 LTSが2021年9月にリリースされ、さらに無償で利用できるとのことで試しにインストールしてみました。
Press Release – オラクル、Java 17をリリース
https://www.oracle.com/jp/news/announcement/java17-jp-2021-09-17/
よりシンプルなライセンス体系の提供
「Oracle JDK 17」および今後のJDKリリースは、次のLTSのリリースから1年後まで、無償で使用できるライセンスの下で提供されます。また、オラクルは2017年以降と同様に、オープンソースであるGeneral Public License(GPL)の下で「Oracle OpenJDK」のリリースを提供していきます。お客様への長期サポートの強化
オラクルは、Javaの開発者コミュニティおよびJCPと協力して、お客様の新しいJava LTSのバージョンへの移行の時期や要否について、より柔軟に対応できるように、LTSのスケジューリングを強化していきます。オラクルは次のLTSのリリースをJava 21とし、2023年9月の提供開始を検討しています。これにより、今後のLTSのリリース・サイクルは3年から2年に変更されます。
※上記サイトから引用
Oracle JAVA 17 LTSが2021年9月リリース、2023年9月に21 LTSがリリース予定、ここから1年後まで無償とすると2024年9月までOracle JAVA 17 LTSが無償で利用できるのかな。
Introducing the Free Java License
https://blogs.oracle.com/cloud-infrastructure/post/introducing-free-java-license
無償で利用できるライセンスはOracle No-Fee Terms and Conditions (NFTC)に基づくと
これからインストールするUbuntu 20にはすでにOpenJDKがインストールされています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
rootlinks@Ubuntu20:~$ java --version openjdk 11.0.13 2021-10-19 OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04) OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.20.04, mixed mode, sharing) rootlinks@Ubuntu20:~$ javac --version javac 11.0.13 rootlinks@Ubuntu20:~$ which java /usr/bin/java rootlinks@Ubuntu20:~$ which javac /usr/bin/javac rootlinks@Ubuntu20:~$ ls -l /usr/bin/java* lrwxrwxrwx 1 root root 22 Dec 28 16:48 /usr/bin/java -> /etc/alternatives/java lrwxrwxrwx 1 root root 23 Dec 28 16:59 /usr/bin/javac -> /etc/alternatives/javac lrwxrwxrwx 1 root root 25 Dec 28 16:59 /usr/bin/javadoc -> /etc/alternatives/javadoc lrwxrwxrwx 1 root root 23 Dec 28 16:59 /usr/bin/javap -> /etc/alternatives/javap rootlinks@Ubuntu20:~$ ls -l /etc/alternatives/java* lrwxrwxrwx 1 root root 43 Dec 28 16:48 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-amd64/bin/java lrwxrwxrwx 1 root root 53 Dec 28 16:48 /etc/alternatives/java.1.gz -> /usr/lib/jvm/java-11-openjdk-amd64/man/man1/java.1.gz lrwxrwxrwx 1 root root 44 Dec 28 16:59 /etc/alternatives/javac -> /usr/lib/jvm/java-11-openjdk-amd64/bin/javac lrwxrwxrwx 1 root root 54 Dec 28 16:59 /etc/alternatives/javac.1.gz -> /usr/lib/jvm/java-11-openjdk-amd64/man/man1/javac.1.gz lrwxrwxrwx 1 root root 46 Dec 28 16:59 /etc/alternatives/javadoc -> /usr/lib/jvm/java-11-openjdk-amd64/bin/javadoc lrwxrwxrwx 1 root root 56 Dec 28 16:59 /etc/alternatives/javadoc.1.gz -> /usr/lib/jvm/java-11-openjdk-amd64/man/man1/javadoc.1.gz lrwxrwxrwx 1 root root 44 Dec 28 16:59 /etc/alternatives/javap -> /usr/lib/jvm/java-11-openjdk-amd64/bin/javap lrwxrwxrwx 1 root root 54 Dec 28 16:59 /etc/alternatives/javap.1.gz -> /usr/lib/jvm/java-11-openjdk-amd64/man/man1/javap.1.gz |
参考サイト
How to Install Oracle Java 17 LTS On Ubuntu, Debian, Linux Mint Or Pop!_OS Via APT PPA Repository
https://www.linuxuprising.com/2021/09/how-to-install-oracle-java-17-lts-on.html
実は下記サイトからjdk-17_linux-x64_bin.debをダウンロードしてインストールしたらエラーになってしまいました。
Java Downloads
https://www.oracle.com/java/technologies/downloads/
1 2 3 4 5 |
rootlinks@Ubuntu20:~$ sudo apt install jdk-17_linux-x64_bin.deb Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package jdk-17_linux-x64_bin.deb |
パッケージが使えない?? パッケージが壊れているの? チェックしても大丈夫なんだけど。
How to fix “Unable To Locate Package”? – (Fix with APT Sources)
https://www.linuxfordevices.com/tutorials/ubuntu/fix-unable-to-locate-package
インストールしようとしているパッケージが/etc/apt/sources.listのサイトにあるかチェックして無ければ”E: Unable to locate package”になるってことかな。
システムの整合性を保つために怪しいパッケージはインストールできないようになってるのか?
Ubuntu使いのユーザには常識なんだろうな。
で、参考サイトのようにPPA Repositoryを使うことにしました。
- PPA repositoryの追加
- Oracle JAVAのインストール
--install-recommends
--no-install-recommends
- 確認
- Oracle JAVAをデフォルトに設定
- 確認
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
rootlinks@Ubuntu20:~$ sudo add-apt-repository ppa:linuxuprising/java [sudo] password for rootlinks: Oracle Java 11 (LTS) and 17 (LTS) installer for Ubuntu (21.10, 21.04, 20.04, 18.04, 16.04 and 14.04), Pop!_OS, Linux Mint and Debian. Java binaries are not hosted in this PPA due to licensing. The packages in this PPA download and install Oracle Java, so a working Internet connection is required. The packages in this PPA are based on the WebUpd8 Oracle Java PPA packages: https://launchpad.net/~webupd8team/+archive/ubuntu/java Installation instructions (with some tips), feedback, suggestions, bug reports etc.: Oracle Java 11: https://www.linuxuprising.com/2019/06/new-oracle-java-11-installer-for-ubuntu.html Oracle Java 17: https://www.linuxuprising.com/2021/09/how-to-install-oracle-java-17-lts-on.html Important notice regarding Oracle Java 11 and 16: the Oracle JDK license has changed starting April 16, 2019. 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. A FAQ is available here: https://www.oracle.com/technetwork/java/javase/overview/oracle-jdk-faqs.html . After this change, new Oracle Java 11 releases (11.0.3 and newer) require signing in using an Oracle account to download the binaries. This PPA has a new installer that requires the user to download the Oracle JDK 11 .tar.gz and place it in a folder, and only then install the "oracle-java11-installer-local" package. Details here: https://www.linuxuprising.com/2019/06/new-oracle-java-11-installer-for-ubuntu.html For Oracle Java 17, the license has changed, stating that JDK 17 binaries are free to use in production and free to redistribute, at no cost, under the Oracle No-Fee Terms and Conditions License. About Oracle Java 10, 12, 13, 14, 15 and 16: These versions have reached the end of public updates, therefore they are longer available for download. The Oracle Java 10/12/13/14/15 packages in this PPA no longer worked due to this, so I have removed them. Switch to Oracle Java 17 or OpenJDK 17 instead, which is long term support. Created for users of https://www.linuxuprising.com/ . More info: https://launchpad.net/~linuxuprising/+archive/ubuntu/java Press [ENTER] to continue or Ctrl-c to cancel adding it. Hit:1 http://jp.archive.ubuntu.com/ubuntu focal InRelease Hit:2 http://jp.archive.ubuntu.com/ubuntu focal-updates InRelease Hit:3 http://jp.archive.ubuntu.com/ubuntu focal-backports InRelease Hit:4 http://archive.ubuntulinux.jp/ubuntu focal InRelease Hit:5 http://archive.ubuntulinux.jp/ubuntu-ja-non-free focal InRelease Hit:6 https://dl.google.com/linux/chrome/deb stable InRelease Hit:7 http://security.ubuntu.com/ubuntu focal-security InRelease Get:8 http://ppa.launchpad.net/linuxuprising/java/ubuntu focal InRelease [18.1 kB] Get:9 http://ppa.launchpad.net/linuxuprising/java/ubuntu focal/main i386 Packages [536 B] Get:10 http://ppa.launchpad.net/linuxuprising/java/ubuntu focal/main amd64 Packages [1932 B] Get:11 http://ppa.launchpad.net/linuxuprising/java/ubuntu focal/main Translation-en [692 B] Fetched 21.2 kB in 3s (7405 B/s) Reading package lists... Done |
--install-recommends
と--no-install-recommends
の違いは?
推奨インストールでいいのかな?
--install-recommends
はそのままインストールが始まりそうです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
rootlinks@Ubuntu20:~$ sudo apt install oracle-java17-installer --install-recommends Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-5.4.0-42 linux-headers-5.4.0-42-generic linux-image-5.4.0-42-generic linux-modules-5.4.0-42-generic linux-modules-extra-5.4.0-42-generic Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: gsfonts gsfonts-x11 oracle-java17-set-default Suggested packages: binfmt-support visualvm ttf-baekmuk | ttf-unfonts | ttf-unfonts-core ttf-kochi-gothic | ttf-sazanami-gothic ttf-kochi-mincho | ttf-sazanami-mincho ttf-arphic-uming The following NEW packages will be installed: gsfonts gsfonts-x11 oracle-java17-installer oracle-java17-set-default 0 upgraded, 4 newly installed, 0 to remove and 12 not upgraded. Need to get 3161 kB of archives. After this operation, 4776 kB of additional disk space will be used. Do you want to continue? [Y/n] |
--no-install-recommends
はライセンス”Oracle No-Fee Terms and Conditions (NFTC)”が表示されてライセンス承認の画面が表示されました。
なので--no-install-recommends
でインストールしました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
rootlinks@Ubuntu20:~$ sudo apt install oracle-java17-installer --no-install-recommends Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-5.4.0-42 linux-headers-5.4.0-42-generic linux-image-5.4.0-42-generic linux-modules-5.4.0-42-generic linux-modules-extra-5.4.0-42-generic Use 'sudo apt autoremove' to remove them. Suggested packages: binfmt-support visualvm ttf-baekmuk | ttf-unfonts | ttf-unfonts-core ttf-kochi-gothic | ttf-sazanami-gothic ttf-kochi-mincho | ttf-sazanami-mincho ttf-arphic-uming Recommended packages: gsfonts-x11 oracle-java17-set-default The following NEW packages will be installed: oracle-java17-installer 0 upgraded, 1 newly installed, 0 to remove and 12 not upgraded. Need to get 31.5 kB of archives. After this operation, 118 kB of additional disk space will be used. Get:1 http://ppa.launchpad.net/linuxuprising/java/ubuntu focal/main amd64 oracle-java17-installer amd64 17.0.1-1~linuxuprising5 [31.5 kB] Fetched 31.5 kB in 1s (31.7 kB/s) Preconfiguring packages ... Selecting previously unselected package oracle-java17-installer. (Reading database ... 217181 files and directories currently installed.) Preparing to unpack .../oracle-java17-installer_17.0.1-1~linuxuprising5_amd64.deb ... Unpacking oracle-java17-installer (17.0.1-1~linuxuprising5) ... Setting up oracle-java17-installer (17.0.1-1~linuxuprising5) ... No /var/cache/oracle-jdk17-installer/wgetrc file found. Creating /var/cache/oracle-jdk17-installer/wgetrc and using default oracle-java17-installer wgetrc settings for it. Downloading Oracle Java 17... --2022-01-22 11:16:27-- http://download.oracle.com/java/17/archive/jdk-17.0.1_linux-x64_bin.tar.gz Resolving download.oracle.com (download.oracle.com)... 23.45.56.109 Connecting to download.oracle.com (download.oracle.com)|23.45.56.109|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://download.oracle.com/java/17/archive/jdk-17.0.1_linux-x64_bin.tar.gz [following] --2022-01-22 11:16:27-- https://download.oracle.com/java/17/archive/jdk-17.0.1_linux-x64_bin.tar.gz Connecting to download.oracle.com (download.oracle.com)|23.45.56.109|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 180723427 (172M) [application/x-gzip] Saving to: 'jdk-17.0.1_linux-x64_bin.tar.gz' 0K ........ ........ ........ ........ 18% 17.7M 8s 32768K ........ ........ ........ ........ 37% 12.3M 7s 65536K ........ ........ ........ ........ 55% 11.5M 6s 98304K ........ ........ ........ ........ 74% 17.4M 3s 131072K ........ ........ ........ ........ 92% 5.83M 1s 163840K ........ .... 100% 6.63M=16s 2022-01-22 11:16:44 (10.5 MB/s) - 'jdk-17.0.1_linux-x64_bin.tar.gz' saved [180723427/180723427] Download done. Removing outdated cached downloads... update-alternatives: using /usr/lib/jvm/java-17-oracle/bin/jpackage to provide /usr/bin/jpackage (jpackage) in auto mode Oracle JDK 17 installed #####Important######## To set Oracle JDK 17 as default, install the "oracle-java17-set-default" package. E.g.: sudo apt install oracle-java17-set-default. Processing triggers for mime-support (3.64ubuntu1) ... Processing triggers for hicolor-icon-theme (0.17-2) ... Processing triggers for gnome-menus (3.36.0-1ubuntu1) ... Processing triggers for shared-mime-info (1.15-1) ... Processing triggers for desktop-file-utils (0.24-1ubuntu3) ... |
デフォルトではまだOpenJDKです。
1 2 3 4 5 6 |
rootlinks@Ubuntu20:~$ java --version openjdk 11.0.13 2021-10-19 OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04) OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.20.04, mixed mode, sharing) rootlinks@Ubuntu20:~$ javac --version javac 11.0.13 |
メッセージにもあるようにoracle-java17-set-defaultパッケージをインストールしてみます。
#####Important########
To set Oracle JDK 17 as default, install the “oracle-java17-set-default” package.
E.g.: sudo apt install oracle-java17-set-default.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
rootlinks@Ubuntu20:~$ sudo apt install oracle-java17-set-default [sudo] password for rootlinks: Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-5.4.0-42 linux-headers-5.4.0-42-generic linux-image-5.4.0-42-generic linux-modules-5.4.0-42-generic linux-modules-extra-5.4.0-42-generic Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: oracle-java17-set-default 0 upgraded, 1 newly installed, 0 to remove and 12 not upgraded. Need to get 2540 B of archives. After this operation, 15.4 kB of additional disk space will be used. Get:1 http://ppa.launchpad.net/linuxuprising/java/ubuntu focal/main amd64 oracle-java17-set-default all 17.0.1-1~linuxuprising5 [2540 B] Fetched 2540 B in 2s (1093 B/s) Selecting previously unselected package oracle-java17-set-default. (Reading database ... 217205 files and directories currently installed.) Preparing to unpack .../oracle-java17-set-default_17.0.1-1~linuxuprising5_all.deb ... Unpacking oracle-java17-set-default (17.0.1-1~linuxuprising5) ... Setting up oracle-java17-set-default (17.0.1-1~linuxuprising5) ... |
Oracle JAVAがデフォルトに切り替わりました。リンクを張り直すだけなのかな。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
rootlinks@Ubuntu20:~$ java --version java 17.0.1 2021-10-19 LTS Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39) Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing) rootlinks@Ubuntu20:~$ javac --version javac 17.0.1 rootlinks@Ubuntu20:~$ which java /usr/bin/java rootlinks@Ubuntu20:~$ which javac /usr/bin/javac rootlinks@Ubuntu20:~$ ls -l /usr/bin/java* lrwxrwxrwx 1 root root 22 Dec 28 16:48 /usr/bin/java -> /etc/alternatives/java lrwxrwxrwx 1 root root 23 Dec 28 16:59 /usr/bin/javac -> /etc/alternatives/javac lrwxrwxrwx 1 root root 25 Dec 28 16:59 /usr/bin/javadoc -> /etc/alternatives/javadoc lrwxrwxrwx 1 root root 23 Dec 28 16:59 /usr/bin/javap -> /etc/alternatives/javap rootlinks@Ubuntu20:~$ ls -l /usr/bin/java*/usr/bin/java* ls: cannot access '/usr/bin/java*/usr/bin/java*': No such file or directory rootlinks@Ubuntu20:~$ ls -l /etc/alternatives/java* lrwxrwxrwx 1 root root 36 Jan 22 11:25 /etc/alternatives/java -> /usr/lib/jvm/java-17-oracle/bin/java lrwxrwxrwx 1 root root 46 Jan 22 11:25 /etc/alternatives/java.1.gz -> /usr/lib/jvm/java-17-oracle/man/man1/java.1.gz lrwxrwxrwx 1 root root 37 Jan 22 11:25 /etc/alternatives/javac -> /usr/lib/jvm/java-17-oracle/bin/javac lrwxrwxrwx 1 root root 47 Jan 22 11:25 /etc/alternatives/javac.1.gz -> /usr/lib/jvm/java-17-oracle/man/man1/javac.1.gz lrwxrwxrwx 1 root root 39 Jan 22 11:25 /etc/alternatives/javadoc -> /usr/lib/jvm/java-17-oracle/bin/javadoc lrwxrwxrwx 1 root root 49 Jan 22 11:25 /etc/alternatives/javadoc.1.gz -> /usr/lib/jvm/java-17-oracle/man/man1/javadoc.1.gz lrwxrwxrwx 1 root root 37 Jan 22 11:25 /etc/alternatives/javap -> /usr/lib/jvm/java-17-oracle/bin/javap lrwxrwxrwx 1 root root 47 Jan 22 11:25 /etc/alternatives/javap.1.gz -> /usr/lib/jvm/java-17-oracle/man/man1/javap.1.gz |
ちなみにoracle-java17-set-defaultをアンインストールしてもOracle JAVAのままです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
rootlinks@Ubuntu20:~$ sudo apt remove oracle-java17-set-default Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-5.4.0-42 linux-headers-5.4.0-42-generic linux-image-5.4.0-42-generic linux-modules-5.4.0-42-generic linux-modules-extra-5.4.0-42-generic Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: oracle-java17-set-default 0 upgraded, 0 newly installed, 1 to remove and 12 not upgraded. After this operation, 15.4 kB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 217210 files and directories currently installed.) Removing oracle-java17-set-default (17.0.1-1~linuxuprising5) ... rootlinks@Ubuntu20:~$ java --version java 17.0.1 2021-10-19 LTS Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39) Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing) |
JAVA_HOMEやPATHを設定すればOpenJDKを使うことはできると思います。