How to Install Java Runtime in Ubuntu

Install Jre In Ubuntu Featured

Java is not installed by default in Ubuntu, but it is required to run Java applications, such as Minecraft, on your computer. This article will show you how to install Java Runtime in Ubuntu.

What Is Java Runtime?

Java is an “interpreted” language, which means the code is not compiled into a ready-to-run executable. To run Java applications, you need to have a translator, known as a “runtime.” This runtime translates the program’s code in real time to instructions our computers understand, allowing us to run it.

Check for Java

To check if you already have Java installed, use:

java -version
Install Jre In Ubuntu Check Java Version

The output will tell you if you already have Java on your computer, and if not, which versions are available to install. Note them down, as you might need them later.

Install Default Version

Out of all available versions of Java, one will be deemed “the default” for your distribution. It might not be a bleeding-edge version, but it’s usually the latest one that is considered stable, secure, and generally “the best” for most uses.

To install it, use:

sudo apt install default-jre
Install Jre In Ubuntu Install Default Jre

After a while, and the installation of some extra dependencies, Java will be installed on your computer.

Install Jre In Ubuntu Installed Default Jre

Use the java -version command again to check which version was installed.

Install Jre In Ubuntu Rerun Java Version

Unfortunately, though, some programs that are created for a specific version of Java might run into problems when using different ones. Thankfully, there are solutions to such problems.

JRE and JDK

To run Java code, you need the Java runtime. In rare cases, though, some related extras may be needed. They can be found in the full-blown Java Development Kit.

To install it, enter in your terminal:

sudo apt install default-jdk
Install Jre In Ubuntu Install Default Jdk

Install (and Switch to) Older Versions

If what you’re trying to run still fails, install an older version of Java just like you did for the default runtime. For example, to install the oldest version available at this time for Ubuntu 20.04, we used:

sudo apt install openjdk-8-jre
Install Jre In Ubuntu Install Older Jdk

You don’t have to uninstall the Java version that’s already installed. Many versions can coexist in parallel. Only one of them is active at any given time, though. Even if you install an older version, that won’t solve the problem of not being able to run that jar file automatically. You first have to switch to the older version. To do that, use:

sudo update-alternatives --config Java
Install Jre In Ubuntu Config Java

A numbered list of the available versions will appear in your terminal. An asterisk before the number will mark the active one. Press Enter on your keyboard to keep the active one or the number that corresponds to a different version followed by Enter to switch to it.

Install Jre In Ubuntu Select Java Version

Install Oracle Java

Stubborn programs may refuse to work with any open version of Java, demanding Oracle’s version. Unfortunately, installing Oracle’s Java is a bit more complicated. You have to manually download it first from Oracle’s official Java page.

Install Jre In Ubuntu Oracle Java Download

Save the file somewhere, fire up a terminal and move to the same directory. Unleash dpkg on the downloaded file with:

sudo dpkg -i DOWNLOADED_JDK_FILENAME

Use the “update-alternatives” command we saw before to actually install the JDK with:

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-14.0.1/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-14.0.1/bin/javac 1

Remember to update the paths of the example for the version of Java you’re installing. Also note that you can switch between the “open” and Oracle’s version of Java like we saw before.

With Java installed, you can install and play Minecraft on Ubuntu.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox