Skip to content

Instantly share code, notes, and snippets.

@eMahtab
Created March 26, 2017 13:37
Show Gist options
  • Save eMahtab/79501b961bf4bb1e3fec59685663b5af to your computer and use it in GitHub Desktop.
Save eMahtab/79501b961bf4bb1e3fec59685663b5af to your computer and use it in GitHub Desktop.
Installing Java on Ubuntu
#Step 1 Download the latest zipped JDK from Oracle's website , most probably you will get it downloaded into Downloads directory
#Step 2 Extract the zipped jdk file in the Downloads directory, follow below commands
cd ~/Downloads
tar -xzf jdk-8u121-linux-x64.tar.gz
#Step 3 Move the extracted jdk directory inside /usr/local directory, follow below command
sudo mv ~/Downloads/jdk1.8.0_121 /usr/local/
#Step 4 Update the alternatives, follow below commands
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/jdk1.8.0_121/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/jdk1.8.0_121/bin/javac" 1
#Step 5 Next create the JAVA_HOME variable and add the path of Java executables to PATH variable,
to do that open the .bashrc file and add following three lines at the end of .bashrc file
export JAVA_HOME="/usr/local/jdk1.8.0_121"
set PATH="$JAVA_HOME/bin:$PATH"
export PATH
Yup thats it !!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment