Install and uninstall jdk 7 in Linux

By | December 1, 2014

Reference: https://www.digitalocean.com/community/tutorials/how-to-manually-install-oracle-java-on-a-debian-or-ubuntu-vps

Note: This particular post is purely for my notes. So, I suggest you to visit the reference site 🙂

Java jdk installation

  • Choose the jdk version from here

    I have chosen jdk7 from here

  • Accept the License and Download:
    # wget --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-linux-i586.tar.gz
    

    (OR) Download the tar file manually from here

  • Install:
    
    # mkdir /usr/java
    # tar -xvzf jdk-7u72-linux-i586.tar.gz -C /usr/java/
    
  • Setting Oracle JDK as the default JVM

    
    # update-alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_72/bin/java 100
    # update-alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_72/bin/javac 100
    # update-alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0_72/bin/javaws 100
    
  • Verify that java has been successfully configured by running:

    
    # update-alternatives --display java
    # update-alternatives --display javac
    # update-alternatives --display javaws
    
  • Check installation:

    # java -version
  • Set the JAVA_HOME for all the users

    #vim /etc/profile
    JAVA_HOME=/usr/java/jdk1.7.0_72
    export PATH=$PATH:$JAVA_HOME/bin
    
    #source /etc/profile
    
  • Check JAVA_HOME for all the users
    
    #echo $JAVA_HOME
    Output: /usr/java/jdk1.7.0_72
    

Java jdk uninstall

  • Remove the link:
    
    #update-alternatives --remove "java" "/usr/java/jdk1.7.0_72/bin/java"    
    #update-alternatives --remove "javac" "/usr/java/jdk1.7.0_72/bin/javac"    
    #update-alternatives --remove "javaws" "/usr/java/jdk1.7.0_72/bin/javaws"
    
  • Remove the java package
    
    #rm -rf /usr/java/jdk1.7.0_72
    

Leave a Reply

Your email address will not be published. Required fields are marked *