Wednesday, 25 May 2022

Java7 installation on ubuntu 18.04 / ubuntu 20.04 (cmd installation)

 

Download the JDK for Linux 32-bit or 64-bit (for example: jdk-7u80-linux-x64.tar.gz)

  1. Navigate to ~/Downloads:

    cd /home/"your_user_name"/Downloads
    
  2. 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/
    
  3. Navigate to /usr/local/java:

    cd /usr/local/java
    
  4. Extract the tarball:

    sudo tar xvzf jdk-7u80-linux-x64.tar.gz
    
  5. Check if tarball has been successfully extracted:

    ls –a
    

    You should see jdk1.7.0_80.

  6. Open /etc/profile with sudo privileges:

     sudo nano /etc/profile
    
  7. Scroll down to the end of the file using arrow keys and add the following lines below at 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
    
  8. 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
    
  9. Reload profile:

    source /etc/profile
    
  10. 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)
    

No comments:

Post a Comment