How to Install Java on Pop!_OS 22.04
Despite most of the web moving away from Java applications and towards browser-integrated apps, there are still some things that require the Java runtime. If you’re on Pop_OS Linux and need the latest version of Java for an app, we can help you.
This guide will go over the various ways you can get the Java runtime environment working on Pop_OS 22.04 (and newer).
How to install Java on Pop!_OS 22.04 – OpenJDK (GUI)
For those on Pop_OS that dislike the terminal, you’ll be happy to know that it is possible to install Java with the GUI. To start, open up the “Pop Shop” on the dock. Once it is open, search for “Synaptic Package Manager” and install it.
Once you’ve installed Synaptic, launch it. Then, find the search button inside the app and select it with the mouse. Type in “openjdk” into the search box and press the Enter key to view the search results.
Look through the search results for “default-jre”. Once you’ve found this in the search results, right-click on it with the mouse, and select the “Mark for installation” option. Selecting this option will tell Synaptic that you wish to install the runtime packages.
Find the “Apply” button in the top-left corner of the Synaptic app and click on it with the mouse. When you select this button, Synaptic will download and install OpenJDK and set it up on your Pop_OS 22.04 system.
How to install Java on Pop!_OS 22.04 – OpenJDK (Terminal)
If you’re a Pop_OS user and don’t mind using the terminal, you’ll be able to use it to download and install the Java Runtime to your computer. To start, open up a terminal window. You can open up a terminal by pressing Ctrl + Alt + T on the keyboard. Or, by searching for “Terminal” in the app menu.
When the terminal window is open, use the apt install command to install the “default-jre” package. This package will contain everything you need to run Java programs. You’ll also need the “default-jre-headless” package.
sudo apt install default-jre default-jre-headless
Upon entering the command above, Pop_OS will ask you for your password. Using the keyboard, enter your password. Then, press the Y key to confirm you wish to install the two Java packages.
Once the OpenJDK JRE packages are installed on your Pop_OS 22.04 system, you will be able to check the version installed by running the following command in a terminal window.
java --version
Assuming everything is installed correctly, the terminal output should look similar to the example below.
openjdk 11.0.15 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1, mixed mode, sharing)
If the terminal doesn’t output anything when the java –version command is run, you may not have installed the Java runtime environment correctly in Pop_OS. Try re-running the installation command to fix the issue.
How to install Java on Pop!_OS 22.04 – Linux x64 binary
The OpenJDK version of the Java Runtime Environment is more than adequate for most Pop_OS 22.04 users. Why? It is easy to install, works well out of the box, and requires no configuration.
Still, if you require the official Oracle version of Java on Pop_OS, you can install it by following the step-by-step instructions below.
Step 1: Download the latest version of Java from the Java.com download page. There is a 64-bit DEB package available. Alternatively, if you prefer to download the latest Java DEB package from the terminal, use the following wget command.
wget https://download.oracle.com/java/18/latest/jdk-18_linux-x64_bin.deb -O ~/Downloads/jdk-18_linux-x64_bin.deb
Step 2: After downloading the Java DEB package to your computer, you can install it on your Pop_OS 22.04 system using the dpkg command. This command will install the package to the Pop_OS Apt system.
cd ~/Downloads/
sudo dpkg -i jdk-18_linux-x64_bin.deb
Step 3: After installing the package to your computer, you’ll notice some errors have occurred on-screen. To fix the issue, use the following apt install -f command.
sudo apt install -f
Step 4: Once the errors are corrected, you’ll need to inform Pop_OS 22.04 of the new version of Java. To do that, execute the following update-alternatives command.
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-18/bin/java" 1
Step 5: After updating the alternatives for Pop_OS 22.04, your computer will now be using the version of Oracle Java. You can confirm you’re running Oracle Java 18 by executing the command java –version.
java --version
java 18.0.2 2022-07-19
Java(TM) SE Runtime Environment (build 18.0.2+9-61)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.2+9-61, mixed mode, sharing)