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:
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:
After a while, and the installation of some extra dependencies, Java will be installed on your computer.
java -version command again to check which version was installed.
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:
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:
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:
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 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.
Save the file somewhere, fire up a terminal and move to the same directory. Unleash
dpkg on the downloaded file with:
Use the “update-alternatives” command we saw before to actually install the JDK with:
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.