How to install Java Runtime in Ubuntu
Java is not installed by default in Ubuntu, but is required to run Java applications, such as Minecraft, on the computer. This article will show you how to install Java Runtime in Ubuntu.
What is Java Runtime?
Java is an 'interpreted' language, meaning that the code is not compiled into an executable ready file. To run Java applications, you need to have an interpreter, called Runtime. This runtime translates program code in real time to instruct the computer to understand and enable the program to run.
Java test
To check that you have installed Java, use:
java -version
The output will tell you whether you have Java on your computer and if not, which versions are available to install. Save as you may need them later.

Install the default version
Among all available versions of Java, one is considered the default version for the distribution. It may not be the latest version, but it is usually the stable, secure and generally the best version for almost any purpose.
To install it, use:
sudo apt install default-jre
After some time and installing some additional dependencies, Java will be installed on the computer.
Use the command java -version
again to check which version has been installed.

However, unfortunately, some programs created for a particular version of Java may have trouble using different versions. Thankfully, there is a solution to such problems.
JRE and JDK
To run Java code, you need Java Runtime. However, in rare cases, some additional extras may be needed. They can be found in the full Java Development Kit.
To install it, enter the following command in Terminal:
sudo apt install default-jdk
Install (and switch to) the older version
If what you have tried still fails, install an older version of Java just like you did with the default Runtime. For example, to install the oldest version available at this time for Ubuntu 20.04, the article used:
sudo apt install openjdk-8-jre
You do not have to uninstall the installed Java version. Multiple versions can coexist in parallel. However, only one of them works at a time. But even if you installed an earlier version, that would not solve the problem of not being able to run the jar file automatically. You must first switch to the older version. To do that, use the command:
sudo update-alternatives --config Java
A numbered list for the available versions will appear in the Terminal. An asterisk before the part number that marks the active version. Press Enter
on the keyboard to keep the active version or select the number corresponding to another version and then press Enter
to switch.

Install Oracle Java
Stubborn programs may refuse to work with any open Java version and require an Oracle version. Unfortunately, installing Oracle Java is a bit more complicated. You must first download it manually from the official Oracle Java page.
Save the file somewhere, activate a terminal and move to the same directory. Get dpkg in the downloaded file with the command:
sudo dpkg -i DOWNLOADED_JDK_FILENAME
Use the update-alternatives
previous command to install 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 example paths with the version of Java you will install. Also note that you can switch between 'open' Java versions and Oracle's Java versions.
You should read it
May be interested
- How to work with workspace in GNOMEworkspace or virtual desktop is a major feature of the linux desktop. it has been around for a long time and is available for almost every linux window manager. read on to learn how to work with multiple workspaces in gnome.
- How to quickly launch Ubuntu virtual machine with Multipassmultipass is a lightweight virtual machine manager that allows you to easily and quickly launch an ubuntu virtual machine. here is how you can do so.
- Use Speedtest CLI to check Internet speed on Debian 10in this article, tipsmake.com will use a linux command line tool named speedtest-cli. it is written in python and uses speedtest.net to check bandwidth.
- How to share a mobile connection from any smartphone to Linuxwhat if you need to keep your linux computer online but don't have wireless or ethernet? the answer is to use tethering. with your smartphone, you can share mobile internet with your computer.
- How to upgrade to Fedora 32if you are upgrading to fedora 32, there are several ways to do so. in this article, readers will learn how to upgrade with the graphics tools available through gnome software and the command line with dnf plugin, dnf-plugin-system-upgrade.
- How to change icons in Gnome 3if you don't like the current files and folders in gnome, you can use a different theme icon. you can change any file or folder icon into a custom icon.