


Ubuntu 20にOpenJDKをインストールしてみました。
Install the Java Runtime Environment
https://ubuntu.com/tutorials/install-jre#1-overview
The Java Runtime Environment (JRE) is required to run Java programs. Nowadays there are many JRE packages available from a variety of projects and companies, but the two most popular on Ubuntu are OpenJDK and Oracle HotSpot. Using one package over the other should not create any functional difference in most applications; however, some prefer OpenJDK over Oracle HotSpot as the former does not contain closed-source components, has a much clearer licensing and support policy, and is maintained as part of the Ubuntu archive, with easier installation and upgrades.
メンテナンスを考えたらUbuntuアーカイブとして提供されているOpenJDKが良さそうです。
Installing OpenJDK JRE
https://ubuntu.com/tutorials/install-jre#2-installing-openjdk-jre
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 |
rootlinks@Ubuntu20:~$ sudo apt install default-jre Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: ca-certificates-java default-jre-headless fonts-dejavu-extra java-common libatk-wrapper-java libatk-wrapper-java-jni openjdk-11-jre openjdk-11-jre-headless Suggested packages: fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei The following NEW packages will be installed: ca-certificates-java default-jre default-jre-headless fonts-dejavu-extra java-common libatk-wrapper-java libatk-wrapper-java-jni openjdk-11-jre openjdk-11-jre-headless 0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. Need to get 39.5 MB of archives. After this operation, 179 MB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 java-common all 0.72 [6816 B] (snip) Processing triggers for fontconfig (2.13.1-2ubuntu3) ... Processing triggers for desktop-file-utils (0.24-1ubuntu3) ... 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 man-db (2.9.1-1) ... Processing triggers for ca-certificates (20210119~20.04.2) ... Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. done. |
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 apt install default-jdk Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: default-jdk-headless libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-11-jdk openjdk-11-jdk-headless x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev Suggested packages: libice-doc libsm-doc libx11-doc libxcb-doc libxt-doc openjdk-11-demo openjdk-11-source visualvm The following NEW packages will be installed: default-jdk default-jdk-headless libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-11-jdk openjdk-11-jdk-headless x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev 0 upgraded, 16 newly installed, 0 to remove and 0 not upgraded. Need to get 226 MB of archives. After this operation, 242 MB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 openjdk-11-jdk-headless amd64 11.0.13+8-0ubuntu1~20.04 [223 MB] (snip) Setting up libpthread-stubs0-dev:amd64 (0.4-1) ... Setting up xtrans-dev (1.4.0-1) ... Setting up default-jdk-headless (2:1.11-72) ... Setting up openjdk-11-jdk:amd64 (11.0.13+8-0ubuntu1~20.04) ... update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode Setting up xorg-sgml-doctools (1:1.11-1) ... Setting up default-jdk (2:1.11-72) ... Processing triggers for sgml-base (1.29.1) ... Setting up x11proto-dev (2019.2-1ubuntu1) ... Setting up libxau-dev:amd64 (1:1.0.9-0ubuntu1) ... Setting up libice-dev:amd64 (2:1.0.10-0ubuntu1) ... Setting up libsm-dev:amd64 (2:1.2.3-1) ... Processing triggers for man-db (2.9.1-1) ... Setting up libxdmcp-dev:amd64 (1:1.1.3-0ubuntu1) ... Setting up x11proto-core-dev (2019.2-1ubuntu1) ... Setting up libxcb1-dev:amd64 (1.14-2) ... Setting up libx11-dev:amd64 (2:1.6.9-2ubuntu1.2) ... Setting up libxt-dev:amd64 (1:1.1.5-1) ... |
1 2 3 4 5 6 7 |
rootlinks@Ubuntu20:~$ java -version openjdk version "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 |
Hello World!
1 2 3 4 5 6 7 8 9 10 11 |
rootlinks@Ubuntu20:~$ vi HelloWorld.java rootlinks@Ubuntu20:~$ cat HelloWorld.java public class HelloWorld { public static void main(String []args) { System.out.println("Hello World! (^^v"); } } rootlinks@Ubuntu20:~$ javac HelloWorld.java rootlinks@Ubuntu20:~$ java HelloWorld Hello World! (^^v |