Here we are going to learn How to install Oracle Java 8 on Ubuntu 18.04. Java and the JVM (Java’s virtual machine) are widely used and required for many kinds of software. This article will guide you through the process of installing and managing different versions of Java using apt-get
Steps to install the Oracle JDK on Ubuntu 18.04:
- First, add Oracle’s PPA
- Update your package repository
- Install Java
- Oracle JDK 8
- Oracle JDK 9
- Managing Java
- Confirm the java version:
If you want to install the Oracle JDK, which is the official version distributed by Oracle, you will need to add Oracle’s PPA repositories first, To do so follow the command below:
After installing the PPA repository for the Oracle Java 8, you need to update the packages and repositories using the following command.
Then, depending on the version you want to install, execute one of the following commands:
This is the latest stable version of Java at time of writing, and the recommended version to install. You can do so using the following command:
This is a developer preview and the general release is scheduled for March 2017. It’s not recommended that you use this version because there may still be security issues and bugs. There is more information about Java 9 on the official JDK 9 website.To install JDK 9, use the following command:
There can be multiple Java installations on one server. You can configure which version is the default for use in the command line by using update-alternatives, which manages which symbolic links are used for different commands.
You can also set the Java 8 as a default Oracle Java Version using below command
You can also open and check the java application graphically using Search your Ubuntu Applications box. Refer to the snapshot below.
Setting the JAVA_HOME Environment Variable
Many programs, such as Java servers, use the JAVA_HOME environment variable to determine the Java installation location. To set this environment variable, we will first need to find out where Java is installed. You can do this by executing the same command as in the previous section:
Copy the path from your preferred installation and then open /etc/environment using nano or your favourite text editor.
At the end of this file, add the following line, making sure to replace the highlighted path with your own copied path.
Save and exit the file, and reload it.
You can now test whether the environment variable has been set by executing the following command:
How To Uninstall Oracle Java 8 Application in Ubuntu 18.04?
To Uninstall Oracle Java 8 Application from your system using the following command.