Which version of Java should you use in Linux? Learn how to easily switch between different versions with a tutorial from Jack Wallen.
You will probably come across a situation where you have to work with different versions of Java; when Linux is your development platform, you can easily switch between them. For instance, if a project requires Java 17, you can switch to that. When your next project requires Java 18, you can quickly make the switch. Let me show you how.
First, we’re going to install Java 17 and Java 18, so you can see how the switching is done.
sudo apt-get install openjdk-17-jdk openjdk-17-jre -y
sudo apt-get install openjdk-18-jdk -y
Now Java 17 and Java 18 are installed on your machine, ready to help you build your projects.
update-alternatives --config java
This will present you with a list of the different versions of Java you have installed. Each version will be associated with a number, starting with 0.
java --version
And that’s all there is to switching between versions of Java on Linux. You can install as many versions as you like and switch between them for different projects on the fly.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.