5/13/2019
73

It’s a pretty straightforward and easy process, and we’ll show you step-by-step instructions on how to install Java on Ubuntu. The instructions would work for Ubuntu 14.04, 16.04, 18.04, and any other LTS release.

This should work for any Ubuntu-based distro, even non-LTS versions like 18.10, but they were tested on Ubuntu 16.04 and Ubuntu 18.04. They should work on both servers and desktops.

In a hurry? Click here and follow the instructions.

Written by: web-keeper-666, Score: -1 votes: 10. Format: Article. How To Install Oracle (Sun) Java JDK & JRE in Ubuntu via PPA. Jul 20, 2018 - A new PPA repository that allows easily installing Oracle Java 10 (JDK) in Ubuntu or Linux Mint. How To Install Java on Ubuntu 12.04 with Apt-Get. If you instead need the Java Development Kit (JDK), which is usually needed to compile Java applications.

Before we begin installing Java

Some things you’ll need before we start installing Java:

  • An Ubuntu server. You can get one from Vultr or any other cloud hosting provider
  • A sudo/root user. All commands below are executed by the root user. If you’re using a non-root user then you’ll need to append ‘sudo’ to most commands.
  • An SSH client like MobaXterm (if you use Windows), or SSH enabled (if you use Ubuntu)
  • Make sure you don’t have Java already installed. If you do, remove it, or if you want to use multiple Java versions/installs, then keep it and configure them later.

So that’s pretty much it.

There are multiple ways of installing Java

We’ll order them based on difficulty (easiest first):

  1. Contact us and we’ll install and configure Java for you (any version, any OS)
  2. Installing the latest Java using the default (Ubuntu’s) JDK using apt-get (use this if you don’t know what to choose)
  3. Installing Java 8 using Oracle’s JDK with apt-get (not recommended)
  4. Installing Java manually using Oracle’s JDK (not recommended for beginners)

How to install Java (the default JDK) on Ubuntu using apt-get


We’ll start with our instructions on how to install the latest recommended version of Java (JDK) using the Ubuntu package. By installing the JDK (Java Development Kit), you’ll also install the JRE (Java Runtime Environment). This is the OpenJDK package which is an open source implementation of Java.

Step 1: Update Ubuntu

The first thing you should always do is update your system. You can do so by running the following commands:

Step 2: Install the default JDK

Run the following command:

And that’s it. Depending on when you’re reading this, the command will either install Java 10 or Java 11. You can now move on to step 3 and configure your Java.

How to install Java 11 using the Oracle JDK

If you don’t want to use Ubuntu’s default open source JDK, you can use the official Oracle JDK through a 3-rd party repository.

Step 1: Update Ubuntu

Again, you should always update your system first before you do anything else. Run the following commands:

And install the required package if you don’t have it already installed:

Step 2: Add the Java repository

The first thing you need to do is add a 3-rd party repository to get the Oracle JDK. We’ll use the one from Linux Uprising, but you can use any other repository:

And then update your package list again:

Step 3: Install Java

So to install the JDK 11th (stable), latest version, run the following command:

And that’s it. You can now move on to step 4 and configure your Java.

How to install Java 8 using the Oracle JDK

To install Java 8 (which will reach its end of life January 2019!), follow these instructions:

Step 1: Update Ubuntu

Again, you should always update your system first before you do anything else. Run the following commands:

Install java on linux ubuntu

And install the required package if you don’t have it already installed:

Step 2: Add the Java repository

The first thing you need to do is add a 3-rd party repository to get the Oracle JDK. We’ll use the one from WebUpd8, but you can use any other repository:

And then update your package list again:

Step 3: Install Java

So to install the JDK 8th, outdated version, run the following command:

And that’s it. You can now move on to step 4 and configure your Java.

How to install Java manually using Oracle’s JDK on Ubuntu

This step is not recommended for beginners. You won’t get updates from Ubuntu’s repositories, you’ll have to manually update your Java each time there’s a new release. If you want to install a custom version of Oracle’s JDK that’s not available via a package, you can follow the steps below.

Step 1: Update

Install Java Jdk On Ubuntu Linux Iso

Install Java Jdk On Linux

As always. Update first:

Step 2: Download the JDK

Go to Oracle’s downloads page and select the version you want to download. We’ll use Java’s Standard Edition 11.0.1 for the purpose of this tutorial. Replace the version numbers if you’re going to use a different version. Java 9 is only available for 64-bit systems, so if your Ubuntu is 32-bit, you must use a different version.

Download the .tar.gz file:

The Java version and this link often change, so please go to the download page yourself and copy the link yourself.

Create a directory for your Java installation:

This is where we’ll install Java. You can use a different directory if you want to install it elsewhere like /usr/local

Step 3: Install Java

Now extract the .tar.gz (tarball) file to the directory you previously created

And that’s it. move on to step 4 and configure your Java.

Setting up Java on Ubuntu

Now it’s time to configure your Java.

Check what Java version you’re using

First, make sure you’ve installed Java on your system and check what version you have:

The output should be something like:

So based on this, we’re using version 11.

Install

Set a default if you have multiple Java installations

If you have multiple Java installations, you can set a default one by using the following command:

You can also use this command to check if you have multiple installations.

You’ll get an output with a list of installed Javas. Press enter to keep the default one without any changes or enter a number to select a different default Java.

Set the JAVA_HOME variable

You’ll most likely need to set the JAVA_HOME variable so other applications can find the location of your Java installation. To find the Java installation path, run the previous command again:

And copy the installation path – second column – under “Path”.

Pentium dual core e5700 specs. Next, open the file “/etc/environment” with a text editor

And add the following line at the end of the file:

Of course, make sure you update the path with the one you previously copied, example:

Save the file and then reload it:

To test if everything’s done right, you can check your JAVA_HOME variable using:

And the output should be your Java installation path.

There are multiple ways of setting up the JAVA_HOME variable, and multiple other variables that you may need to set, depending on what you need and what you’re going to use.

If you need any help or have any questions, leave a comment.

energylogix – 2019