How to Install Java on Ubuntu, The Must Read Guide
How to Install Java on Ubuntu!
Ubuntu is a well-known and efficient type of operating system. It was primarily created based on the distribution of Debian Linux. This kind of operating system had been used on huge numbers of web servers these days. This is the reason why more and more people are using this kind of system.
This operating system is also recognized because of its reliability and speed. You can have the chance to install many supporting software into this operating system to be used for several applications. Java is an important and commonly used programming language that supports huge numbers of operating system.
How to Install Java on Ubuntu
Do you want to have Java packages to be installed in your own Ubuntu operating system? If yes, then how are you going to do that? Well, there is nothing to worry about since the steps are very easy and simple. In this guide, you will learn simple yet effective steps on how to install Java on Ubuntu with the use of some commands.
Getting To Know What Apt-Get Is
Apt-get is a powerful command line program of Ubuntu. This program installs, upgrade some software packages at the same time remove those old ones. APT or Advanced Packaging Tool is a tool that can update the whole operating system.
Installing Default JRE/JDK on Ubuntu
Ubuntu 12.04 as well as its earlier version utilizes Open JDK 6 as their default version. Ubuntu 12.10 plus+ version utilizes the Open JDK 7.
Well, you can easily install such default Java. The first and initial step to upgrade the packages is to use the command; sudo apt-get install
After that, you may now see some terminal running commands the same as this:
selvakumar@noisalesteam2:~$ sudo apt-get update
[sudo] password for selvakumar:
Ign http://dl.google.com stable InRelease
Hit http://dl.google.com stable Release.gpg
Hit http://security.ubuntu.com wily-security InRelease
Hit http://dl.google.com stable Release
Hit http://security.ubuntu.com wily- security/main Sources
Hit http://us.archive.ubuntu.com wily InRelease
Hit http://dl.google.com stable/main amd64 Packages
Hit http://security.ubuntu.com wily- security/restricted Sources
Hit http://security.ubuntu.com wily-security/universe Sources
Hit http://us.archive.ubuntu.com wily-updates InRelease
Hit http://security.ubuntu.com wily-security/multiverse Sources
Hit http://us.archive.ubuntu.com wily-backports InRelease
Hit http://security.ubuntu.com wily-security/main amd64 Packages
Hit http://security.ubuntu.com wily-security/restricted amd64 Packages
Hit http://us.archive.ubuntu.com wily/main Sources
…………..
Reading Packages list done….
Once this is already done, you need to determine whether the Java is already installed in the system or not. Part on how to install Java on Ubuntu is to make use of this command
java –version
If the Java is already installed in your operating system, command will be able to return to its java version. But, if it is not successfully installed, messages will be shown.
elvakumar@noisalesteam2:~$ java -version
The program ‘java’ can be found in the following packages:
* default-jre
* gcj-4.9-jre-headless
* gcj-5-jre-headless
* openjdk-7-jre-headless
* gcj-4.8-jre-headless
* openjdk-6-jre-headless
* openjdk-8-jre-headless
When these messages appeared, it is a sign that Java is not successfully installed in your operating system. How to install java on Ubuntu –make use of the following commands
udo apt-get install default-jre
After using the command, you can now see some execution lines of the command like this
selvakumar@noisalesteam2:~$ sudo apt-get install default-jre
[sudo] password for selvakumar:
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
libntdb1 python-ntdb
Use ‘apt-get autoremove’ to remove them.
The following extra packages will be installed:
ca-certificates-java default-jre-headless fonts- dejavu-extra java-common
libatk-wrapper-java libatk-wrapper-java-jni libgnomevfs2-0
libgnomevfs2-common libsctp1 lksctp-tools openjdk-7-jre
openjdk-7-jre-headless tzdata tzdata-java
Suggested packages:
equivs libgnomevfs2-bin libgnomevfs2-extra gamin fam gnome-mime-data
icedtea-7-plugin icedtea-7-jre-jamvm sun-java6- fonts fonts-ipafont-gothic
fonts-ipafont-mincho ttf-wqy-microhei ttf-wqy- zenhei fonts-indic
Recommended packages:
libgnome-2-0
The following NEW packages will be installed:
ca-certificates-java default-jre default-jre- headless fonts-dejavu-extra
java-common libatk-wrapper-java libatk-wrapper- java-jni libgnomevfs2-0
libgnomevfs2-common libsctp1 lksctp-tools openjdk-7-jre
openjdk-7-jre-headless tzdata-java
The following packages will be upgraded:
tzdata
1 upgraded, 14 newly installed, 0 to remove and 71 not upgraded.
Need to get 42.0 MB of archives.
After this operation, 66.0 MB of additional d disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu/ wily/main libsctp1 amd64 1.0.16+dfsg-2 [8,414 B]
Get:2 http://us.archive.ubuntu.com/ubuntu/ wily/main java-common all 0.52 [131 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ wily/main default-jre-headles
Now that it is done, Java is already installed in the operating system.
Apart from the above-mentioned commands, you can do some other installations. These installations are not as necessary however if for some instances you need them, you can just install the applications with the use of the commands which will be mentioned below.
Installation of Open JDK
In installing open JDK on your Ubuntu operating system, you can make use of the command below.
sudo apt-get install openjdk-7-jre
This kind of command can immediately install the Java Run Time Environment in your system. If the open JDK is properly installed, return messages will be like this
selvakumar@noisalesteam2:~$ sudo apt-get install openjdk-7-jre
[sudo] password for selvakumar:
Reading package lists… Done
Building dependency tree
Reading state information… Done
openjdk-7-jre is already the newest version.
openjdk-7-jre set to manually installed.
The following packages were automatically installed and are no longer required:
libntdb1 python-ntdb
Use ‘apt-get autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 71 not upgraded.
If you require JDK to be installed, make use of the command below. This command can download and install packages.
sudo apt-get install openjdk-7-jdk
Installation of Oracle JDK
You can also install Oracle KDK to your Ubuntu operating system using the following command.
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Installation of Oracle JDK 7
This version is still in use and if you want to download and then install it, makes use of the command below.
sudo apt-get install oracle-java7-installer
Installation of Oracle JDK 8
How to install Java on Ubuntu with Oracle JDK 8 – you can make use of the following command below.
sudo apt-get install oracle-java8-installer
Managing Java
You can install different versions of Java to your Ubuntu operating system. However, if you have more than one type of Oracle Java version in your operating system, you need to select which of the versions for you to use. You can only do this by following the command below.
sudo update-alternatives –config java
This type of command will return the entire Java installation that you have. This will appear to be the same as below.
selvakumar@noisalesteam2:~$ sudo update-alternatives –config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
————————————————————
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 auto mode
1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
* 2 /usr/lib/jvm/java-8- oracle/jre/bin/java 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number:
You need to press the number in the lists to choose the desired Java version you want.
Setting the Home Environment of Java Variable
Part on how to install Java on Ubuntu is to set the home environment of Java Variable. In order to do this, you need to determine the java installation path. After that, execute the command mentioned below.
sudo update-alternatives –config java
The path of installation will be like this.
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-8-oracle/jre/bin/java
After that, you can run this command in editing the path
sudo nano /etc/environment
The file will be opened and replaced with your chosen path. You need to copy and then paste your chosen path here.
JAVA_HOME=”Your selected path.”
Save your file. Reload it if necessary.
sudo nano /etc/environment
Then, check your chosen path with the following command.
echo $JAVA_HOME
If it returned to the path of home set, it only means that you are setting the Java path correctly. If not, try to check again the above-mentioned steps and see if you were able to do it correctly.
There are different ways on how to install java on Ubuntu apart from the above-mentioned ways. However, it is considered the easiest and simplest means that will definitely help you to get into the right track of Java installation in your Ubuntu operating system