How To

How to Upgrade Java on Amazon Linux

Java version on Amazon Linux instance created from AMI version 2017.09.01 can be upgraded with following steps. These may work with recent version of Amazon Machine Images (AMIs).

Step 1: Copy the required version of Java to Amazon Linux

For this exercise we would be upgrading to Oracle Java 8 update 121 utilizing package jdk-8u121-linux-x64.rpm which can be downloaded from Oracle Downloads.

Once downloaded this can be copied to the Amazon Linux instance with Secure Copy Protocol (SCP).

Step 2: Remove currently installed Java version

List current Java version information with following command.

$ java -version
java version "1.7.0_161"
OpenJDK Runtime Environment (amzn- u161-b00)
OpenJDK 64-Bit Server VM (build 24.161-b00, mixed mode)

List currently installed Java package.

$ sudo yum list installed '*java*'

Remove currently installed Java package.

$ sudo yum remove java-1.7.0-openjdk.x86_64 -y

Verify Java is uninstalled.

$ java -version
-bash: /usr/bin/java: No such file or directory

Step 2: Install newer version of Java

Navigate to the location where newer version of Java was copied.

$ pwd
$ ls

Run following command to install Java.

$ sudo rpm -ivh jdk-8u121-linux-x64.rpm

Verify that Java is successfully installed.

$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

$ echo $JAVA_HOME

$ which java


Categories: How To

Tagged as:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s