How to Install Java on Ubuntu {Easy Tutorial With Screenshots}

How to Uninstall Java on Ubuntu Verify Java is Installed on Your system initiation
Java is one of the most popular program languages. It is used for developing anything from lightweight mobile to desktop applications.

This bit-by-bit guide will show you how simple it is to install Java on Ubuntu 18.04 or 20.04 .
How to install Java on Ubuntu.
Note: This guide provides instructions that work on Ubuntu 18.04, Ubuntu 20.04 and any other Ubuntu-based distribution ( including Linux Mint, Kubuntu, and Elementary OS ). If you are looking for other Java installation guides, please denote to :

  • Installing Java on Fedora
  • Installing Java on CentOS 7 or CentOS 8
  • Installing Java on Raspberry Pi

Prerequisites

  • A user account with sudo privileges
  • Access to the command-line/terminal window
  • The apt (apt-get) command

Java Versions

There are four Java platforms available :

  1. Java Standard Edition (Java SE)
  2. Java Micro Editions (Java ME)
  3. Java Enterprise Edition (Java EE)
  4. JavaFX

In this document, we look at different packages within the Java SE .
The Ubuntu depository offers two ( 2 ), open-source Java packages, Java Development Kit ( Open JDK ) and Java Runtime Environment ( Open JRE ). You use JRE for running Java-based applications, while JDK is for developing and programming with Java .
besides available is Oracle Java, another SE implementation, which has extra commercial features. You can find the official Oracle JDK through a third-party repository. however, bear in mind the license lone allows non-commercial use of the software .

Installing Java on Ubuntu

You can install one or respective Java packages. You can besides decide which version you want on your system by installing a specific adaptation act. The current nonpayment and LTS interpretation is Java 11 .

Install OpenJDK

1. Open the terminal ( Ctrl + Alt + T ) and update the software depository to ensure you download the latest software translation :

sudo apt update

2. then, you can confidently install the latest Java Development Kit with the follow command :

sudo apt install default-jdk

3. Confirm the facility by typing y ( yes ) and crush Enter .
Command to install default Java Development Kit on Ubuntu.

Install OpenJRE 11

1. Before you install the Java Runtime Environment, make certain you update the depository with :

sudo apt update

2. adjacent, type in the be instruction to download and install Java RE :

sudo apt install default-jre

type y ( yes ) and press Enter to confirm the initiation .
Install Java Runtime Enviorment on Ubuntu.

Install Oracle Java 11

To download the official Oracle JDK, you first need to download a third-party repository .
We include instructions for installations from 2 ( two ) unlike package repositories. You can decide from which one you prefer to download .

Option 1: Download Oracle Java from Webupd8 PPA

1. First, add the compulsory package repository by typing :

sudo add-apt-repository ppa:webupd8team/java

Hit Enter when prompted .
2. Make sure to update your system before initiating any installation :

sudo apt update

3. nowadays, you can install Java 11, the latest LTS translation :

sudo apt install oracle-java11-installer

4. optionally, you can set this Java adaptation as the nonpayment with the take after command :

sudo apt install oracle-java11-set-default

Option 2: Download Oracle Java from Linux Uprising PPA

1. Before adding the new depository, install the command packages if you do not have them on your system so far :

sudo apt install software-properties-common

2. next, add the depository with the adopt instruction :

sudo add-apt-repository ppa:linuxuprising/java

3. Update the box tilt before installing any new software with :

sudo apt update

4. then, download and install the latest version of Oracle Java ( version phone number 11 ) :

sudo apt install oracle-java11-installer

Verify Java is Installed on Your System

immediately verify whether the software is separate of your system .
To check the version of Java running, use the command :

java –version

The successful installation of Java on Ubuntu will end product details, as in the image below .
Confirm the version of Java thatis currently installed. If there is no Java version, the organization will say it is unable to find the software .
Image shows that no version of Java was found.

Install Specific Version of Java

If for some reason you do not wish to install the default or latest version of Java, you can specify the version number you prefer .

Install Specific Version of OpenJDK

You may decide to use Open JDK 8, alternatively of the default option OpenJDK 11 .
To do therefore, open the terminal and character in the follow command :

sudo apt install openjdk-8-jdk

Image shows hoe to install specific version of JDK. Verify the translation of java installed with the command :

java –version

How to check the version of JDK installed.

Install Specific Version of Oracle Java

When you download the Oracle Java packages from a third-party repository, you have to type out the version total as contribution of the code .
consequently, if you want other versions of Java Oracle on your system, change that count accordingly .
The dominate for installing Oracle JDK is the follow ( the symbol # representing the Java version ) :

sudo apt install oracle-java#-installer

For case, if you want to install Java 10, use the control :

sudo apt install oracle-java10-installer

Command to install Java 10 on Ubuntu.

How to Set Default Java Version

As you can have multiple versions of Java installed on your system, you can decide which one is the default one .
beginning, run a control that shows all the install versions on your computer :

sudo update-alternatives --config java

How to select the default Java version. The effigy above shows that there are two alternatives on this system. These choices are represented by numbers 1 ( Java 11 ) and 2 ( Java 8 ), while the 0 refers to the current default interpretation .
As the end product instructs, you can change the default translation if you type its associate number ( in this case, 1 or 2 ) and imperativeness Enter .

How to Set JAVA_HOME Environment Variable

The JAVA_HOME environment variable determines the location of your Java facility. The varying helps other applications access Java ’ s initiation path well .
1. To set up the JAVA_HOME variable, you first need to find where Java is installed. Use the follow command to locate it :

sudo update-alternatives --config java

Set up Java Home Varialbe Enviornment. The Path section shows the locations, which are in this case :

  • /usr/lib/jvm/java-11-openjdk-amd64/bin/java (where OpenJDK 11 is located)
  • /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java (where OpenJDK 8 is located)

2. once you see all the paths, copy one of your prefer Java adaptation .
3. then, open the file /etc/environment with any text editor program. In this example, we use Nano :

nano /etc/environment

4. At the end of the file, add a line which specifies the localization of JAVA_HOME in the follow manner :

JAVA_HOME=”/your/installation/path/”

For exemplar, if we copied the facility path for Java 11 in the previous step, the lend note in the text code editor program would be :
Installation path for Java 11.

How to Uninstall Java on Ubuntu

In case you need to remove any of the Java packages installed, use the apt remove command .
To remove Open JDK 11, run the command :

sudo apt remove default-jdk

To uninstall OpenJDK 8 :

sudo apt remove openjdk-8-jdk

once you run the command, confirm the good continuation of the process by pressing y ( yes ) and the packages will be removed .

Note: Refer to our comprehensive breakdown of Best Java IDEs to find the best one for your needs .
conclusion

This guide has shown you how to install Java on Ubuntu 18.04. It besides instructed you on how to change the default adaptation and set the home environment variable .
now, you are cook to use the mighty Java platform !
For more tutorials on how to install Java on early systems, make indisputable to read our article on how to install Java on Windows .

beginning : https://thefartiste.com
Category : Tech

About admin

I am the owner of the website thefartiste.com, my purpose is to bring all the most useful information to users.

Check Also

articlewriting1

Manage participants in a zoom meeting webinar

Call the people who attend the meet as follows Alternate host host Who scheduled the …

Leave a Reply

Your email address will not be published.