Installing multiple JDK in Linux

Before we begin installing Java in our system, we should check if it is already installed or not. To do so we can run the below command in our terminal:

java -version

If Java is already installed in your system, it will print something like this:-

openjdk version "11.0.14" 2022-01-18
OpenJDK Runtime Environment (build 11.0.14+9-Ubuntu-0ubuntu2.22.10)
OpenJDK 64-Bit Server VM (build 11.0.14+9-Ubuntu-0ubuntu2.22.10, mixed mode, sharing)

if it’s not present already, it usually shows something similar to this:-

Command 'java' not found, but can be installed with:
sudo apt install openjdk-11-jre-headless
sudo apt install default-jre
sudo apt install openjdk-17-jre-headless
sudo apt install openjdk-8-jre-headless
sudo apt install openjdk-15-jre-headless
-------- maybe some more suggestions to install -------

Suppose java is not installed and you see the default suggestions given in the terminal output, you can notice here that the suggestions are only about installing selective versions of OpenJDK as the only vendor.

💡

What if…
- you want to install any other version of Java?
- you want the Java from different vendors?
- you need to install & keep multiple Java versions same time?

This post has an answer to all your questions, keep reading…

Installing Java from OpenJDK

To install Java from OpenJDK, go to https://openjdk.java.net. This is the official website to download the Free OpenSource Java builds for all major platforms and is backed by a huge community and the Oracle team.

In the Download section, you will see a link pointing to the latest stable version of JDK. The link will be similar to jdk.java.net/17. Click on it. And you will be able to see the list of builds for major platforms.

You can click on the archive name to start the download process.
Bonus: Unlike Oracle’s commercial Java builds, here we don’t need to accept any terms & conditions.

comments powered by Disqus

Releted Posts

Go From Zero, Part 12: Building a REST API with the Standard Library

This is Part 12 of 12 in Go From Zero, a beginner-to-production series on the Go programming language. If you missed it, Part 11: Best Practices for Production-Ready Go is the place to catch up.

Read more

Go From Zero, Part 11: Best Practices for Production-Ready Go

This is Part 11 of 12 in Go From Zero, a beginner-to-production series on the Go programming language. If you missed it, Part 10: Testing, Benchmarks, and Fuzzing is the place to catch up.

Read more

Go From Zero, Part 10: Testing, Benchmarks, and Fuzzing

This is Part 10 of 12 in Go From Zero, a beginner-to-production series on the Go programming language. If you missed it, Part 9: Generics Without the Headache is the place to catch up.

Read more