I would like to install java on an Amazon linux2 EC2 instance.
After launching and executing sudo yum update
, check if java is included
[ec2-user@ip-10-0-0-127 ~]$ java -version
-bash: java: command not found
I don't think it's in
Find 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....
Select and install JRE or JDK (including development commands such as javac) according to your requirements
# JDK1.8.Install 0
$ sudo yum install -y java-1.8.0-openjdk-devel.x86_64
Enable Java 8
[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)
The end
Reference source https://www.yoheim.net/blog.php?q=20180101
Recommended Posts