4

I'm on 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 a apt upgrade and apt-upgrade, but the java version is still 10.

Question: how can I safely upgrade my java installation to JDK 11 GA? If I have to add a repository, which one should I use? May I have to uninstall the existing jdk first?

And 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 at 9:49
2

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>
           -a|--auto
           -h|-?|--help
  • How could I achieve the same with openjdk? Due to licensing issues I would want to avoid the original oracle installer... – membersound Nov 7 '18 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 '18 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 '18 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. – membersound Nov 7 '18 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.