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.
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.
Some things you’ll need before we start installing Java:
So that’s pretty much it.
We’ll order them based on difficulty (easiest first):
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.
The first thing you should always do is update your system. You can do so by running the following commands:
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.
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.
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:
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:
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.
To install Java 8 (which will reach its end of life January 2019!), follow these instructions:
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:
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:
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.
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.
As always. Update first:
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
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.
Now it’s time to configure your Java.
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.
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.
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.