How to upgrade Java on Ubuntu?

272,555

Solution 1

Note: WebUpd8 team's PPA has been discontinued with effective from April 16, 2019. Thus this PPA doesn't have any Java files. More information can be found on PPA's page on Launchpad. Hence this method no longer works and exists because of historical reasons.

Use ppa :

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

if you want java8 :

sudo apt-get install oracle-java8-installer

If you ABSOLUTELY need to have the latest update of java you must manualy install from official source, follow this tuto : http://www.cyberciti.biz/faq/howto-installing-oracle-java7-on-ubuntu-linux/

But I advise you to wait as ppa update

Solution 2

Note: WebUpd8 team's PPA has been discontinued with effective from April 16, 2019. Thus this PPA doesn't have any Java files. More information can be found on PPA's page on Launchpad. Hence this method no longer works and exists because of historical reasons.

The newest OpenJDK Java packaged for trusty (14.04) right now is 7u55. You can check your Java version with java -version from the command line in Terminal.

If you want a newer one your best options will be to:

  • wait for an update from Ubuntu, OR

  • install the Oracle distribution of Java which currently is at 7u65:

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

Solution 3

Found something useful here..

Installing Java with apt-get is easy. First, update the package index:

 sudo apt-get update

Check if Java is not already installed:

 java -version

Then install java jre/jdk :

 sudo apt-get install default-jre

 sudo apt-get install default-jdk

For details please go to : https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get

Solution 4

Updated for Ubuntu 18.04

Use ppa :

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

For more infos see: http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html

if you want java9: (Now some Programs like JabRef still need Java8)

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

On http://www.webupd8.org/2015/02/install-oracle-java-9-in-ubuntu-linux.html you can see a detailed explanation how to install Java9, and how to change it to default.

if you want Java 10:

sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo apt install oracle-java10-installer

For more infos see: https://www.linuxuprising.com/2018/04/install-oracle-java-10-in-ubuntu-or.html

if you want Java 11:

sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-11-jdk

If you need the latest update you can download it from

If you have problems to install the latest updates see: https://www.cyberciti.biz/faq/howto-installing-oracle-java7-on-ubuntu-linux/

This question uses content from

Solution 5

Another possible solution is to add the PPA repository from the project ubuntu-justched available in the Github. This will provide a little bit different solution because it will download the Oracle JRE tarball to a previously configured directory and generate a DEB package from it.

That way you won't depend on somebody else packing the JRE, you will do it yourself (don't worry, it will be an automatic process).

Share:
272,555

Related videos on Youtube

kenneth
Author by

kenneth

Updated on September 18, 2022

Comments

  • kenneth
    kenneth almost 2 years

    I installed Ubuntu on my computer, and now my Java version is not updated. I have Java, so I don't need to install - just update the current version.

    Can someone please tell me the command I have to use to get the current version?

    I have tried: apt-get update and apt-get upgrade.

    • Benoit
      Benoit almost 10 years
      How did you first install Java ? Is it a version provided from the Ubuntu repositories ?
  • kenneth
    kenneth almost 10 years
    I tried this one but it will not install the newest version. I have checked it out on java-website. I have now version 7 update 65 and I want version 7 update 67.
  • kenneth
    kenneth almost 10 years
    I have 32-bit computer.
  • kenneth
    kenneth almost 10 years
    root@ubuntu:/home/kenneth# sudo apt-get install oracle-java7-installer Reading package lists... Done Building dependency tree Reading state information... Done oracle-java7-installer is already the newest version. 0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
  • kenneth
    kenneth almost 10 years
    I have recently update from 12.04 version to 14.04 version if this means anything?
  • kenneth
    kenneth almost 10 years
    kenneth@ubuntu:~$ java -version java version "1.7.0_65" Java(TM) SE Runtime Environment (build 1.7.0_65-b17) Java HotSpot(TM) Server VM (build 24.65-b04, mixed mode)
  • akafred
    akafred almost 10 years
    Well, in this case there is no obvious reason why Danish banks are not accepting 7u65, because 7u67 (released Aug 4th, four days ago) has only one bugfix in it - which does not seem security related.
  • Nymeria
    Nymeria almost 10 years
    I have update my reply
  • kenneth
    kenneth almost 10 years
    Okay, I found out it was only my bank who didnt accept access (Nordnet.dk) they are having trouble with NEM-ID in connection with java (crazy mandatory system, required by law), but told me another way to get in. Problem solved then - thanks.
  • Michael Durrant
    Michael Durrant over 8 years
    This worked great for me in March 2016. my system is always fairly up-to-date so just the last two commands (the installs) did it for up
  • Admin
    Admin about 8 years
    +1 for likely relevant answer. For curious users, the rationale of this solution is explained in this blog post.
  • Shaig Khaligli
    Shaig Khaligli almost 8 years
    "E: Unable to locate package oracle-java8-installer" erro while installing
  • Nymeria
    Nymeria almost 8 years
    @ShaigKhaligli did you add the ppa and do "apt update" before trying to install java ?
  • Shaig Khaligli
    Shaig Khaligli almost 8 years
    yes I did. My currently java version is 1.7 and I want to upgrade it. I am using debian
  • Nymeria
    Nymeria almost 8 years
    If you using debian, you can't add ppa ! You have to add depot, follow this tutorial : webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.h‌​tml
  • santu
    santu over 7 years
    I just updated using - sudo apt-get update, and this resolved my issue.
  • karel
    karel over 6 years
    There have been several new questions posted in the past two months asking what to do because oracle-java9-installer returns this error: download failed Oracle JDK 9 is NOT installed. dpkg: error processing package oracle-java9-installer (--configure): subprocess installed post-installation script returned error exit status 1 . oracle-java8-installer returns the same error: download failed Has this problem been fixed?
  • JoKalliauer
    JoKalliauer over 6 years
    @karel can you explain how to reproduce the error (or add one or two Questions where to find them?) I installed Java8 and Java9 sudo apt-get install oracle-java8-installer sudo apt-get install oracle-java9-installer and set sudo apt-get install oracle-java8-set-default Java 8 as default. and I do not have any problems at all
  • karel
    karel over 6 years
    All I wanted to know is if oracle-java8-installer and oracle-java9-installer are working now, so I could update this answer.
  • JoKalliauer
    JoKalliauer over 6 years
    @karel Actually I only tested it on Ubuntu 16.04. I did not get any warinings installing them.
  • karel
    karel over 6 years
    You see what my problem is is that Oracle changed the location of its Java 8 and Java 9 files and what am I supposed to do now? Am I supposed to check back every day to see if the ppa is up-to-date again and I can start recommending people to use it again? I use the open source JDK from the Ubuntu repos because that's what Oracle uses to build its Java binaries anyway.
  • Kalpesh Soni
    Kalpesh Soni about 6 years
    Cannot add PPA: 'ppa:webupd8team/java'. Please check that the PPA name or format is correct.