Installing java on linux based system is not a headache, if you are following the right way.
- First of all you have to download latest jdk from oracle http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
- There are x86 and x64 versions, you have to choose which is gonna fit on your machine. After choosing your architecture you need to download it. The package is available in two formats, 1. *.tar.gz 2. *.rpm. I personally prefer the hard way, so i choose tar.gz. Its not a big deal.
- After downloading the file must be located in your downloads folder. Now we are going to deal with the package.
Open Terminal by CTRL + T or as you like. Type cd Downloads
tar xvzf “your complete file name with extension”
eg: tar xvzf jdk-8u121-linux-x64.tar.gz
Now you can see a new folder on your downloads, do not close your terminal unless we complete.
Now we are going to move this folder into a safe location where we need the root access. Usually i use the path /usr/lib/jvm/jdk8
We have to create a folder named jdk8 on the /usr/lib/jvm/. So follow the command sudo mkdir /usr/lib/jvm/jdk8
Now move our folder by sudo mv “your folder name” /usr/lib/jvm/jdk8
Make sure that you have all the files inside /usr/lib/jvm/jdk8
Now we have all the necessary files inside our safe location. Now we have to tell our OS where we put our jdk. For that we have to edit your bashrc. To do that
Then goto the last line of your bashrc, then copy and paste these lines there
Now we have to load it, so perform the command source ~/.bashrc
Type javac and enter on terminal to see whether we have succeed or not
Perform a reboot, there you go…