install jdk-13.0.2 on linux code example

Example: how to install java jdk 13 on linux

sudo apt install -y curl
curl -O https://download.java.net/java/GA/jdk13/5b8a42f3905b406298b72d750b6919f6/33/GPL/openjdk-13_linux-x64_bin.tar.gz
tar xvf openjdk-13_linux-x64_bin.tar.gz

sudo mv jdk-13 /opt/
  sudo tee /etc/profile.d/jdk.sh <<EOF
  export JAVA_HOME=/opt/jdk-13
  export PATH=\$PATH:\$JAVA_HOME/bin
  EOF
  
source /etc/profile.d/jdk13.sh

echo $JAVA_HOME

java -version

### Second Approach to install java 13 along side other java versions
## Check this link https://medium.com/@ayeshajayasankha/how-to-install-and-switch-between-alternative-java-versions-66b3671fc382

curl -O https://download.java.net/java/GA/jdk13/5b8a42f3905b406298b72d750b6919f6/33/GPL/openjdk-13_linux-x64_bin.tar.gz
tar xvf openjdk-13_linux-x64_bin.tar.gz
export JAVA_HOME=<Directory where JAVA has been extracted>/jdk-13
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
. /etc/profile
sudo update-alternatives --install "/usr/bin/java" "java" "<Directory where JAVA has been extracted>/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "<Directory where JAVA has been extracted>/bin/javac" 1  
sudo update-alternatives --set java <Directory where JAVA has been extracted>/bin/java
sudo update-alternatives --set javac <Directory where JAVA has been extracted>/bin/javac
java -version
javac -version

Tags:

Java Example