I'm on Ubuntu 18.04 with default-java -> java-1.11.0-openjdk-amd64/. java -version shows:

OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.3, mixed mode)

I already did an apt upgrade and apt-upgrade, but the java version is still 10.

How can I safely upgrade my Java installation to JDK 11 GA? If I have to add a repository, which one should I use? Do I have to uninstall the existing JDK first?

How can I then make the new Java version the default-java?

  • 2
    Incidentally, does anyone know why this is the case? The whole point was supposed to be that Ubuntu would upgrade to JDK 11 GA when it got released
    – NealeU
    Jan 29, 2019 at 9:49

1 Answer 1


To add the LinuxUprising Java PPA repository to your software sources and install Oracle Java 11 in Ubuntu 18.04 run the following commands:

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

The oracle-java11-installer package automatically installs the oracle-java11-set-default package, which sets Oracle Java 11 as default (including setting the JAVA_HOME environment variable, which requires a session restart).

You don't need to uninstall openjdk-11-jdk if you already have installed it. You can use update-java-alternatives (which is installed when openjdk-11-jdk is installed) to manually choose which Java to use before running an application.

$ update-java-alternatives
usage: update-java-alternatives [--jre-headless] [--jre] [--plugin] [-v|--verbose]
           -l|--list [<jname>]
           -s|--set <jname>
  • How could I achieve the same with openjdk? Due to licensing issues I would want to avoid the original oracle installer... Nov 7, 2018 at 9:42
  • @membersound It's very easy to achieve the same result with openjdk, but I strongly recommend that you don't do it this way because if openjdk is installed this way it will not be updated automatically if updates are available. It's too risky, but if you want the official Ubuntu JDK package in 18.04 visit these 3 webpages and manually download them: 1 2 3
    – karel
    Nov 7, 2018 at 9:49
  • Uninstall the existing openjdk-11-jdk. Double-click each .deb file to install it with Ubuntu Software app or open the terminal, change directories using cd to the folder that contains the .deb files and install each .deb file like this: sudo apt install ./package-name.deb
    – karel
    Nov 7, 2018 at 9:51
  • 1
    Ok I see. As I anyway need a fixed java version on the target machine and only want to update it manually (to prevent undesired results with running applications), I just went for: sudo add-apt-repository ppa:openjdk-r/ppa, sudo apt install openjdk-11-jdk. Nov 7, 2018 at 10:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .