October 11, 2023
October 11, 2023

How To Select Which Version of Java to Use in Linux (+ Video)

Advertisements


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.

  1. To install Java 17, open a terminal window and issue this command:
sudo apt-get install openjdk-17-jdk openjdk-17-jre -y
  1. After that installation completes, let’s install Java 18 with this command:
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.

  1. To switch between Java versions, issue this command:
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.

  1. If you want to switch to Java 18, locate and type the associated number for Java 18 and hit Enter on your keyboard. The system will set Java 18 as the current version. You can verify the switch with the following command, where you should see Java 18 listed:
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.



Source link

61 Bridge Street
Kingdon
Herts
Top locations – from restaurants and clubs, to galleries, famous places Local Business Directory - Events - Jobs - Classifieds and so much more...
© 2023 All Rights Reserved By StepInto Group Ltd
crossmenu