How can I upgrade to Java 1.8 on an Amazon Linux Server?

Solution 1:

To remove java 1.7 and install java 1.8:

sudo yum install java-1.8.0
sudo yum remove java-1.7.0-openjdk

Solution 2:

Install Java Runtime 1.8

sudo yum install java-1.8.0

or if you need a java compiler and other developer tools:

sudo yum install java-1.8.0-openjdk-devel

Then use the alternatives command to make Java 1.8 the default.

sudo /usr/sbin/alternatives --config java
sudo /usr/sbin/alternatives --config javac
# etc

If you prefer you can remove Java 1.7 with

sudo yum remove java-1.7.0-openjdk

but remove it after you installed Java 1.8 or the aws-apitools will also be removed as they depend on Java on being installed.


Solution 3:

yum install java-1.8.0 -y
/usr/sbin/alternatives --set java /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
/usr/sbin/alternatives --set javac /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/javac
yum remove java-1.7.0-openjdk