General / Server / install and setup JDK
Install and setup JDK
-
STEPS
1. download jdk
//version 1 wget https://corretto.aws/downloads/latest/amazon-corretto-17-x64-linux-jdk.tar.gz tar -xvf amazon-corretto-17-x64-linux-jdk.tar.gz //version 2 wget https://corretto.aws/downloads/latest/amazon-corretto-8-aarch64-linux-jdk.tar.gz tar -xvf amazon-corretto-8-aarch64-linux-jdk.tar.gz OR sudo apt update sudo apt install openjdk-8-jdk openjdk-11-jdk 2. Set JAVA_HOME
set path of jdk folder which contains bin file
Save the changes to .bashrc and reload it:export JAVA_8_HOME=/usr/lib/jvm/java-8-openjdk-amd64 export JAVA_11_HOME=/usr/lib/jvm/java-11-openjdk-amd64 export PATH=$JAVA_8_HOME/bin:$PATH source ~/.bashrc Switching Between JDK Versions:
export JAVA_HOME=$JAVA_11_HOME export PATH=$JAVA_HOME/bin:$PATH source ~/.bashrc Check version
java -version