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.

How to install Java Runtime in Ubuntu Picture 1 The result of the command indicates that Java is not installed

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 -versionagain to check which version has been installed.

How to install Java Runtime in Ubuntu Picture 2 Use the java -version command 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 Enteron the keyboard to keep the active version or select the number corresponding to another version and then press Enterto switch.

How to install Java Runtime in Ubuntu Picture 3 Select the number corresponding to another version and press Enter to convert

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-alternativesprevious 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.

4.5 ★ | 2 Vote

May be interested

  • How to Enable Oracle Java in Your Web Browsers on Ubuntu LinuxHow to Enable Oracle Java in Your Web Browsers on Ubuntu Linux
    this document covers enabling 32-bit and 64-bit oracle java browser plugin in 32-bit ubuntu linux and 64-bit ubuntu linux. for the two most popular web browsers for ubuntu linux at this time, which are google chrome and mozilla firefox....
  • How to Upgrade Oracle Java on Ubuntu LinuxHow to Upgrade Oracle Java on Ubuntu Linux
    this document is intended to assist with the upgrade of the many new release versions of oracle java jdk/jre on ubuntu linux. every so often, due to bug fixes and security issues oracle releases updates to their version of the java...
  • How to install Ubuntu in parallel with Windows using USBHow to install Ubuntu in parallel with Windows using USB
    installing ubuntu in parallel with windows 7 and 8 with usb will help users not to waste time writing files to disk, running on many different computers.
  • How to install Microsoft Visual C ++ 2015 RuntimeHow to install Microsoft Visual C ++ 2015 Runtime
    if you start a program and get an error that says the program you are trying to run needs the microsoft visual c ++ 2015 runtime, you can use this guide to install the package and get the program working again.
  • How to Install Android on Ubuntu Linux with Eclipse IDEHow to Install Android on Ubuntu Linux with Eclipse IDE
    this document will prepare an overview of the steps you will take to install and configure android on your ubuntu linux system. you must have oracle java jdk or openjdk on your system before installing android sdk. openjdk (aka open java...
  • How to Install JDK in LinuxHow to Install JDK in Linux
    this wikihow teaches you how to install the latest version of jdk (java 12) on debian, ubuntu, and linux mint using the linux rising ppa repository. press to open a new terminal window. if you're already at the command prompt, just skip to...
  • How to install Java on the computerHow to install Java on the computer
    how to install java on the computer. currently, there are still a lot of applications running on the computer on java, so installing java on the computer is a must. for example, those of you who are accountants who regularly have to file electronic tax returns are definitely ph
  • How to fix 'The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing from your computer'How to fix 'The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing from your computer'
    if you get the error message 'api-ms-win-crt-runtime-l1-1-0.dll is missing', it means that universal crt, part of visual c ++ redistributable did not install properly or the file api-ms-win-crt-runtime-l1-1-0.dll is missing or corrupt.
  • How to install multiple Java versions on CentOS 8How to install multiple Java versions on CentOS 8
    java is one of the most widely used high-level programming languages. in this article, readers will learn how to install different versions of java on centos 8.
  • What is Java? Why choose Java?What is Java?  Why choose Java?
    what is java? java is a high-level programming language, developed by sun microsystem and released in 1995. java runs on a variety of platforms, such as windows, mac and various versions of unix.