How to Install Java in Ubuntu
Table of Contents
If you are a bit into computers you must know that Java is a must for several or I would say many important applications. By default JDK is not installed in Ubuntu, so to use your system to its full extent we have to install it separately.
Oracle JAVA 8 is the stable release and available to download and install on the official download page.
Oracle Java PPA for Ubuntu is maintained by Webupd8 Team and can be downloaded from there easily, setting everything for you automatically.
Here is a tutorial to install Oracle Java 17 and Oracle Java 20 on your distro.
The webupd8 ppa no longer has Java installer. Most Linux distributions default ppa has Java installer available. Please use the following command to install Java in your Ubuntu based Linux distro.
Install Java from default PPA
sudo apt install openjdk-11-jre
sudo apt install openjdk-11-jdk
To install a different Java version, replace ’11’ with the version number.
How To Install Java in Ubuntu?
No longer works. Instead, try the above method.
Basically we will have to install the packages and then run the installer. Java will be installed easily.
Step 1: Add the PPA
To add the PPA open the terminal (Ctrl+Alt+T) and run the following command –
This requires admin rights so we will have to use sudo.
For Oracle Java 7/8:
sudo add-apt-repository ppa:webupd8team/java
To enter the password after running this command and press Enter.
Press Enter again to add.
Step 2: Update system
After adding Java repo we need to update the system using apt command –
Use the command :
sudo apt update
Step 3: Run the installer. The installer installs Java on your computer.
On running it, it asks for some permissions which you must grant.
Run the following command :
For Oracle Java 7:
sudo apt-get install oracle-java7-installer
For Oracle Java 8:
sudo apt-get install oracle-java8-installer
Next screen will appear for the license agreement, so press OK.
The next screen will ask if you want to install. Choose YES and press Enter.
Your system now has Java installed.
Step 4: Configure Java’s default variables
To automatically set up the Java 7 environment variables JAVA_HOME and PATH:
sudo apt-get install oracle-java7-set-default
To automatically set up the Java 8 environment variables JAVA_HOME and PATH:
sudo apt-get install oracle-java8-set-default
Enjoy the power of Java on your system. For any assistance or problem ask me in the comment box.
LinuxAndUbuntu Newsletter
Join the newsletter to receive the latest updates in your inbox.