Skip to content

Installing OpenJDK for Mac and Linux

Rishabh Poddar edited this page Apr 22, 2021 · 3 revisions

For Linux (for Ubuntu)

  1. Download OpenJDK 15.0.1 from here

  2. Create the /usr/java directory:
    sudo mkdir /usr/java

  3. Navigate to the directory where the archive was downloaded and move the archive to the new directory:
    mv openjdk-15.0.1_linux-x64_bin.tar.gz /usr/java

  4. Go to this directory:
    cd /usr/java

  5. Unpack archive:
    sudo tar -xzvf openjdk-15.0.1_linux-x64_bin.tar.gz

  6. Set the environment variables, for this open the /etc/profile file and add the text mentioned below to the end of the file:

JAVA_HOME=/usr/java/jdk-15.0.1
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin  
export JAVA_HOME  
export JRE_HOME  
export PATH
  1. Check Java version:
    java -version

For Mac

  1. Download OpenJDK 15.0.1 from here
  2. Navigate to the directory where the archive was downloaded and extract the file
    tar -xzvf openjdk-15.0.1_osx-x64_bin.tar.gz
  3. Install the JDK
    sudo mv jdk-15.0.1.jdk /Library/Java/JavaVirtualMachines/
  4. Check java version:
    java -version
  5. In case you do not see openjdk version "15.0.1", then you need to switch the default to that version. This stackoverflow answer will guide you.
Clone this wiki locally