Install Jdk on Ubuntu
Learn about how to install Jdk on Ubuntu
To Check Java version being used
1 | java -version |
Install OpenJDK 8. The typical installation path is /usr/lib/jvm/java-8-openjdk-amd64/
1 | sudo apt install openjdk-8-jdk |
Optional: install OpenJDK 8 source code
1 | sudo apt install openjdk-8-source |
Install OpenJDK 11. The typical installation path is /usr/lib/jvm/java-11-openjdk-amd64/
1 | sudo apt install openjdk-11-jdk |
Optional: install OpenJDK 11 source code
1 | sudo apt install openjdk-11-source |
To get OpenJDK 17
1 | sudo apt install openjdk-17-jdk |
To check the Java Home environment variable
1 | echo $JAVA_HOME |
Setup environment variable, edit ~/.bashrc file
1 | # Java |
To set default JDK
1 | sudo update-alternatives --config java |
Reference