How to Install Oracle JDK 7 on Ubuntu 18.10 Cosmic Gnu/Linux

October 6, 2018 | By the+gnu+linux+evangelist.

Oracle JDK 7 Ubuntu 18.10 - Setting Up

  1. Next Relocate Oracle JDK 7 Contents
    Login as the SuperUser:

    sudo su

    If Got “User is Not in Sudoers file” then see: How to Enable sudo
    To Make a jvm Directory Only if Not already there
    (You can directly copy & paste the commands into the terminal)

    if [ ! -d "/usr/lib/jvm" ]; then mkdir /usr/lib/jvm; fi

    Set the root superUser as owner

    sudo chown -R root:root /tmp/jdk1.7*

    Then to shift the Oracle JDK 7 contents

    mv /tmp/jdk1.7* /usr/lib/jvm/
    
  2. Installing Oracle Java JDK 7

    update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7*/bin/java 1065
    
    update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7*/bin/javac 1065
    
    update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.7*/bin/jar 1065
    
    update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.7*/bin/javaws 1065
    

    Checking or Setting the System Java Version in Use
    with

    update-alternatives --config java

    And for the Java Compiler instead:

    sudo update-alternatives --config javac

    To Switch of Java Version Just Enter the Selection Number on First, Column. :)
    Last Achieve the SuperUser session:

    exit
  3. Setting JAVA_HOME User Environment Variable (Optional).

    Edit the Bash environment Configuration file:

    nano $HOME/.bashrc

    Append:

    export JAVA_HOME=/usr/lib/jvm/jdk1.7[uX]

    Replace the [uX] Looking for the Installed Java 7 Version with:

    ls /usr/lib/jvm/

    Ctr+x to Save & Exit from nano Editor :)
    Next to Load the New Bash Environment:

    bash

QuickChic Theme • Powered by WordPress