11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Amazon linux2 にjava 1.8.0をインストールする

Posted at

Amazon linux2 EC2インスタンスにjavaをインストールしたいと思います。

立ち上げてsudo yum updateを実施後、javaが入っているか確認する

[ec2-user@ip-10-0-0-127 ~]$ java -version
-bash: java: command not found

入ってなさそうですね

javaを探す

[ec2-user@ip-10-0-0-127 ~]$ sudo yum search java
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
============================== N/S matched: java ===============================
aether-javadoc.noarch : Java API documentation for Aether
ant-antunit-javadoc.noarch : Javadoc for ant-antunit
ant-contrib-javadoc.noarch : Javadoc for ant-contrib
ant-javadoc.noarch : Javadoc for ant
ant-javamail.noarch : Optional javamail tasks for ant
antlr-javadoc.noarch : Javadoc for antlr
aopalliance-javadoc.noarch : API documentation for Java/J2EE AOP standards
apache-commons-beanutils-javadoc.noarch : Javadoc for apache-commons-beanutils
apache-commons-cli-javadoc.noarch : Javadoc for apache-commons-cli
apache-commons-collections-javadoc.noarch : Javadoc for
                                          : apache-commons-collections
apache-commons-collections-testframework-javadoc.noarch : Javadoc for
                                                        : apache-commons-collections-testframework
apache-commons-dbcp-javadoc.noarch : Javadoc for apache-commons-dbcp
apache-commons-exec-javadoc.noarch : Javadocs for apache-commons-exec
apache-commons-jexl-javadoc.noarch : Javadocs for apache-commons-jexl
apache-commons-pool-javadoc.noarch : Javadoc for apache-commons-pool
apache-commons-validator-javadoc.noarch : Javadoc for apache-commons-validator
apache-commons-vfs-javadoc.noarch : Javadoc for apache-commons-vfs
apache-rat-javadoc.noarch : Javadocs for apache-rat
aqute-bnd-javadoc.noarch : Javadoc for aqute-bnd
aqute-bndlib-javadoc.noarch : Javadoc for aqute-bndlib....

要件に合わせて、JREまたはJDK(=javacなど開発系コマンドを含む)を選んでインストール

# JDK1.8.0をインストール
$ sudo yum install -y java-1.8.0-openjdk-devel.x86_64

Java8を有効化する

[ec2-user@ip-10-0-0-127 ~]$ sudo alternatives --config java

There is 1 program that provides 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2.x86_64/jre/bin/java)

Enter to keep the current selection[+], or type selection number: 1
[ec2-user@ip-10-0-0-127 ~]$ java -version
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)

おしまい

参考元
https://www.yoheim.net/blog.php?q=20180101

11
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?