Java is a programming language and computing platform. It was first released by Sun Microsystems in 1995. A lot of devices, programs, and services require having Java installed before to work properly. Installing Java in Ubuntu 17.04 is almost similar to the installing Java in the previous version of Ubuntu such as Ubuntu 16.04. Here, we are going to explain how to install Java in Ubuntu 17.04.
- Recommended: Installing and configuring LAMP in Ubuntu 17.04
We assume that you are already familiar with managing packages in Ubuntu. If you are interested, you can read the following article. These articles describe the complete step by step guide about how to manage packages in Ubuntu Linux
Steps To Install Java In Ubuntu
In order to install Java in Ubuntu, you need to perform the following steps.
Updating Existing Packages
Keeping up-to-date system is always recommended. First of all, execute the following command to update the package index and the older packages.
sudo apt-get update -y sudo apt-get upgrade -y
Checking Current Version of Java
Once your Ubuntu (in this case 17.04) system is updated, execute the following command to check whether Java is already installed or not.
Installing Java Runtime in Ubuntu
If the Java is not installed already, use the following command to install Java.
sudo apt-get install default-jre -y
Installing JDK In Ubuntu
Once you installed the Java Runtime Environment (JRE), next you probably also need to install Java Development Kit (JDK). JDK is needed to compile the Java programs and applications such as Apache Maven. In order to install JDK in Ubuntu 17.04, use the following commands:
sudo apt-get install default-jdk –y
Use the java -version command to verify again that the Java is installed successfully.
Installing Java Installer
In order to install Java installer such as Java Update 8 Installer, first, add the java package repository. After that update the package index using the following commands.
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update -y
Now, execute the following command to begin the Java 8 installation in Ubuntu.
sudo apt-get install java-common oracle-java8-installer -y
Note: It may take some time to complete the installation.
To install an earlier version, such as Java 7 Installer in Ubuntu 17.04, use the following command.
sudo apt-get install java-common oracle-java7-installer -y
During the installation process, you will need to accept the license agreement. The following figure shows the Java License Agreement screen.
Set Default Java Version In Ubuntu
If there are multiple Java versions installed, you may need to make a specific Java version as the default Java version. This is accomplished using the following command.
sudo update-alternatives --config java
On the keep the current choice prompt, select the default version of Java as shown in the below-mentioned figure.
That’s all you need to install, update, and set the default java version in Ubuntu 16.04 and Ubuntu 17.04. If you get stuck anywhere, please drop your queries in the comment box. We will get in touch with you. You may also like, share, and subscribe us to keep yourself up-to-date for upcoming articles.
Also read: How to reset root password in Ubuntu 17.04