Installing
-
2. Downloading
Download Oracle Java SE JDK8 for Linux.
-
3. Extracting
Then Extract into /tmp
Possibly Double-Click/Right-Click and Open with Archive Manager:
Or from Shell:tar xvfz ~/Downloads/jdk-8*.tar.gz -C /tmp/
-
4. Installing
Then to Install Oracle JDK 8
First, Make a jvm Directory if Not already there with:su -c 'if [ ! -d "/usr/lib/jvm" ]; then mkdir /usr/lib/jvm; fi'
Set the root superUser as owner:
sudo chown -R root:root /tmp/jdk1.8*
Again reiterate the Execution Permission also over the Java binaries:
sudo chmod -R +x /tmp/jdk1.8*/bin
Finally, to Shift the Java contents:
sudo mv /tmp/jdk1.8* /usr/lib/jvm/
-
5. Updating
Finally, Update System Java to Oracle JDK 8
Run All these Commands below:sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8*/bin/java 1065
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8*/bin/javac 1065
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.8*/bin/jar 1065
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.8*/bin/javaws 1065
Then to Check or Set the System Java Version in Use do:
sudo update-alternatives --config java
To Switch of Java Version Just Enter the Selection Number on First, Column. :)
-
6. Setting Up JAVA_HOME
Finally, to Set Up JAVA_HOME User Environment Variable (Optional)
And Edit the User’s Bash environment Configuration file:nano $HOME/.bashrc
And Append:
export JAVA_HOME=/usr/lib/jvm/jdk1.8[uX]
Replace the [uX] Looking for the Installed Java 8 Version with:
ls /usr/lib/jvm/ | grep jdk1.8
Ctr+x to Save & Exit from nano Editor :)
To Load New Bash Config simply:bash
Contents