Installing Java 7, 8, and 9 on Ubuntu and Linux Mint

This topic was published by and viewed 3721 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author
    Posts

  • DevynCJohnson
    Keymaster
    • Topics - 437
    • @devyncjohnson

    Java is used by many computer users. Obviously, Ubuntu and Linux Mint users need Java and they may wish to use Java 7, 8, or 9. Currently, Oracle's Java is not in the default repos, so here is how users can install it.

    Java 7

    Run the below code in a command-line with Root privileges.

    add-apt-repository ppa:webupd8team/java
    
    apt-get update
    
    apt-get install oracle-java7-installer

    Running "apt-get install oracle-java7-set-default" will set the global Java 7 system/environment variables and remove the variables of other Java versions.

    Java 8

    Run the below code in a command-line with Root privileges.

    add-apt-repository ppa:webupd8team/java
    
    apt-get update
    
    apt-get install oracle-java8-installer

    The "oracle-java8-installer" package downloads an installer that obtain Java from Oracle directly. Java itself is not in the PPA.

    Running "apt-get install oracle-java8-set-default" will set the global Java 8 system/environment variables and remove the variables of other Java versions..

    Java 9

    Run the below code in a command-line with Root privileges to obtain Java 9 on Ubuntu, Linux Mint, and other distros that support PPAs.

    add-apt-repository ppa:webupd8team/java
    
    apt-get update
    
    apt-get install oracle-java9-installer

    Verify Installations

    Java installations can be verified by executing "java -version" or "javac -version".

    Switch Between Javas

    To make Java 7 the default, run "update-java-alternatives -s java-7-oracle". Alternately, to make Java 8 the default, run "update-java-alternatives -s java-8-oracle". Obviously, "update-java-alternatives -s java-9-oracle" makes Java 9 the default. All of these commands require Root privileges.

Viewing 1 post (of 1 total)