Easy guide on how to install Java on Ubuntu systems
Java is a high level programming language that is being used for a large number of applications & is installed on large number of servers/systems. We have already covered how we can install java on CentOS/RHEL systems . In this tutorial , we are going to discuss how to install Java on Ubuntu systems.
With Ubuntu, we have option to either use the default Ubuntu’s java , which is recommended if you are not sure which java to use or we can also use Oracle’s java. We will check how to install java on Ubuntu for both the java types. So let’s start……
(Recommended Read: Installing JAVA 7 & 8 on Centos/RHEL 7)
Installing Default Ubuntu Java
For installing the default version of Ubuntu’s java, we need not add any repositories as the package has been provided with the default Ubuntu’s repo. To install it, simply open terminal & execute the following command,
$ sudo apt-get update
For installing JRE only,
$ sudo apt-get install default-jre
To install Java JDK (it includes JRE also), run the following command,
$ sudo apt-get install default-jdk
This is the easiest way to install java on Ubuntu systems. Now let’s discuss the installation for Oracle java.
Installing Oracle JDK
For installing Oracle JDK, we firstly need to add a repository for the same,
$ sudo add-apt-repository ppa:webupd8team/java
Than update the repo on the system,
$ sudo apt-get update
We can now install the latest version of Java using the following command,
$ sudo apt-get install oracle-java8-installer
Similarly, if need to install java 7 run the following command,
$ sudo apt-get install oracle-java7-installer
Or for installing java 9, execute the following command from terminal,
$ sudo apt-get install oracle-java9-installer
After installation you can check the installed java version by running the following command,
$ java –version
Next step is to set the java environment variables. To do this, open the file ‘.bashrc’ from your home folder,
$ sudo nano ~/.bashrc
& add the following content,
JAVA_HOME=/usr/java/jdk1.8.0_151 # change the path as per the installed java version
Save the file & exit. That’s it on our tutorial on how to install java on the Ubuntu systems.
If facing any error or have any suggestions, please do mention them using the comment box below.
If you have found this article to be useful, please share it among your friends/colleagues/followers. THANKS !!!