How To Install Temurin OpenJDK 17 on Amazon Linux 2

About Java Programming Language

Eclipse Adoptium

Eclipse Adoptium Projects Uniqueness

  • TCK Testing Infrastructure: A large-scale initiative aimed at ensuring conformity and interoperability by executing Java SE TCKs.
  • Development Kits and Runtimes: Accessible on a wide range of processor core and system software combinations, and supporting the APIs defined by different Java SE editions.
  • Techniques for getting and controlling the installation of runtime technologies include system local installers, container images, download servers, a webpage, and artifact repositories.
  • JDK Mission Control is a set of low-cost Java Virtual Machine monitoring and debugging tools.

Install Temurin OpenJDK 17 on Amazon Linux 2

Step 1- Update Amazon Linux 2

sudo yum update -y

Step 2- Install Temurin OpenJDK 17 on Amazon Linux 2

sudo yum install wget

wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.2%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.2_8.tar.gz
tar xzf OpenJDK17U-jdk_x64_linux_hotspot_17.0.2_8.tar.gz

Step 3- Configure Java Environment Variables

sudo mv jdk-17.0.2+8/ /opt/jdk-17
$ vim ~/.bashrc

export JAVA_HOME=/opt/jdk-17

export PATH=$PATH:$JAVA_HOME/bin
source ~/.bashrc
$ echo $JAVA_HOME

/opt/jdk-17



$ java -version

openjdk version "17.0.2" 2022-01-18

OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8)

OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)

Step 4- Setting Java default version

sudo update-alternatives --install /usr/bin/java java /opt/jdk-17/bin/java 1
$ sudo update-alternatives --config java



There are 2 programs which provide 'java'.



Selection Command

-----------------------------------------------

* 1 /opt/jdk-17/bin/java

+ 2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-1.amzn2.0.3.x86_64/bin/java)



Enter to keep the current selection[+], or type selection number: 1
$ java -version

openjdk version "17.0.2" 2022-01-18

OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8)

OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)

Step 5- Setting Global JAVA_HOME Environment Variable

$ whereis java

java: /usr/bin/java /usr/lib/java /etc/java /usr/share/java /opt/jdk-17/bin/java
sudo vim /etc/profile
JAVA_HOME="/path/to/java/install"
export JAVA_HOME=/opt/jdk-17

export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
$ echo $JAVA_HOME

/opt/jdk-17

Test Temurin OpenJDK 17 on Amazon Linux 2

cat > hello_world.java <public class helloworld 

public static void main(String[] args)

System.out.println("Hello World! I LOVE Using Temurin in my Development because it is very POWERFUL");





EOF
$ java hello_world.java

Hello World! I LOVE Using Temurin in my Development because it is very POWERFUL

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ComputingPost

ComputingPost — Linux Howtos, Tutorials, Guides, News, Tips and Tricks.