Download the JDK for Linux 32-bit or 64-bit (for example: jdk-7u80-linux-x64.tar.gz)
Navigate to ~/Downloads:
cd /home/"your_user_name"/Downloads
Create a a directory in /usr/local where java will reside and copy tarball there:
sudo mkdir -p /usr/local/java
sudo cp -r jdk-7u80-linux-x64.tar.gz /usr/local/java/
Navigate to /usr/local/java:
cd /usr/local/java
Extract the tarball:
sudo tar xvzf jdk-7u80-linux-x64.tar.gz
Check if tarball has been successfully extracted:
ls –a #you should see jdk1.7.0_80
Open /etc/profile with sudo privileges:
sudo nano /etc/profile
Scroll down to the end of the file using arrow keys and add the following lines below to the end of /etc/profile file:
JAVA_HOME=/usr/local/java/jdk1.7.0_80
JRE_HOME=/usr/local/java/jdk1.7.0_80
PATH=$PATH:$JRE_HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Update alternatives:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.7.0_80/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_80/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.7.0_80/bin/javaws" 1
sudo update-alternatives --set java /usr/local/java/jdk1.7.0_80/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_80/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jdk1.7.0_80/bin/javaws
Reload profile:
source /etc/profile
Verify installation:
java -version
You should receive a message which displays:
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
Social