Oracle Java Installation on Linux

Just Copy and Paste then Execute in terminal 

Java Installation On Linux
**************************************

# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz

# sudo mkdir /usr/java

# sudo mv jdk-8u141-linux-x64.tar.gz /usr/java/

# cd /usr/java/

# sudo tar -xvf jdk-8u141-linux-x64.tar.gz

# cd jdk1.8.0_141/

# sudo update-alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_141/bin/java 1100
# sudo update-alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_141/bin/javac 1100

# sudo update-alternatives --display java
# sudo update-alternatives --display javac

# java -version

# sudo vi /etc/profile.d/java.sh //Add the following lines

#!/bin/bash
JAVA_HOME=/usr/java/jdk1.8.0_25/ //Replace "jdk1.8.0_25" with your present JAVA Version
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME
export CLASSPATH=. //save and exit

# sudo chmod +x /etc/profile.d/java.sh

# su or sudo su

# source /etc/profile.d/java.sh //works on CentOS

# echo $JAVA_HOME
# echo $PATH

Note : Delete or uninstall any existing java versions on your machine before you start this installation 
# yum remove java*
# apt purge java*


Listing exixting Java on machine
**************************************

# Yum update
Then, search for if any older JDK versions are installed in your system.

# rpm -qa | grep -E '^open[jre|jdk]|j[re|dk]'

Download rpm file and 
Then, go to the directory where you’ve downloaded the jdk package, and run the following command to install it.

# rpm -ivh jdk-8u*.rpm     //Replace jdk-8u* with your downloaded rpm file

# rpm -q --whatprovides java //In addition, users can now check which specific RPM package provides the java files


Oracle Java 8 installation on Ubuntu via PPA
*************************************************
(PPA supports Ubuntu 16.10, 16.04, 15.10, 14.04 and 12.04 as well as Linux Mint 18, 17.x and 13. Add the PPA and install Oracle Java 8 (the package provides both JDK8 and JRE8) )

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java8-installer

sudo apt-get install oracle-java8-set-default //if you want to set Oracle Java 8 as default

sudo apt-get install --no-install-recommends oracle-java8-installer //If you don't want to make Oracle Java 8 default



On Debian via PPA
**************************

# su -

# echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list

# echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list

# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886

# apt-get update

# apt-get install oracle-java8-installer

# exit

For automatic license accepting for Java
************************************************

echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections

or

echo oracle-java8-installer shared/accepted-oracle-licence-v1-1 boolean true | sudo /usr/bin/debconf-set-selections



Reference Links:
*****************************
1) https://www.unixmen.com/install-oracle-java-jdk-8-centos-76-56-4/
2) http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html
3) http://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_server_jre.html

Comments