Java 17 version released by Oracle comes with new features and improvements to the Java programming language. If you’re running Amazon Linux 2023 and need to install Java 17, then Corretto is the best way to get it. Here in this quick guide, we take you through the process step by step to get Java 17 which offers enhanced performance, new language features, and improvements that can benefit your applications.
Step 1: Update AL2023 Packages
Go to your AWS Cloud to directly access the Amazon Linux 2023 server’s terminal or use the local ssh to remotely connect it. Of course, you must have sudo access to install packages on it. Once you have the command terminal, first execute the given command to update the package repository and existing packages.
sudo dnf update
Step 2: Installing Java 17 on Amazon 2023 Linux
Amazon Corretto is a distribution of the Open Java Development Kit (OpenJDK) developed and maintained by the Amazon Web Services (AWS) Team. This is designed to use on the AWS Linux platform to get a number of benefits when running Java applications.
And the best part is we can install Java 17 Corretto directly using the default system repository of Amazon 2023 Linux, here is the command to follow:
For JRE 17
sudo dnf install java-17-amazon-corretto
For JDK 17
sudo dnf install java-17-amazon-corretto-devel
Step 3: Check installed JAVA Version
By following the above commands you will definitely have the Java 17 version you want to install on your Amazon Linux 2023. To confirm that we can use the given command.
Step 4: How to Switch between Java versions
If you have multiple Java versions installed on your Amazon Linxu 2023 let’s say you have both Java 8 and Java 17 on your system.
Now, to switch between and make any one of them the default Java version of your system, we can use the “alternative –config” command.
alternatives --config java
Type the Selection number of the Java you want to set as default system one and hit the Enter key.