Skip to content

Instantly share code, notes, and snippets.

@jkeam
Created July 12, 2020 04:53
Show Gist options
  • Save jkeam/3a6cc976ecbc0d48d5b54ffa97a89cd9 to your computer and use it in GitHub Desktop.
Save jkeam/3a6cc976ecbc0d48d5b54ffa97a89cd9 to your computer and use it in GitHub Desktop.
Instructions on how to install and manage Java in Ubuntu 20

Java Installation and Management in Ubuntu 20

Installation

sudo apt-get install openjdk-8-jdk

# don't worry, you can apt-get multiple java versions
sudo apt-get install openjdk-11-jdk
#sudo apt-get install openjdk-...  <tab complete to see all available versions>

Management

# list available javas
update-java-alternatives --list  # you should see 8 and 11 if you followed my instructions from above
sudo update-java-alternatives --set /path/to/java/version  # you will get the right path from the previous step

# make sure to have this line in your .bashrc or .zshrc
# export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:bin/javac::")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment