Now it is possible to install openjdk-11 this way:
sudo apt-get install openjdk-11-jdk
(Previously it installed openjdk-10, but not anymore)
Answer from user5479362 on Stack OverflowVideos
Now it is possible to install openjdk-11 this way:
sudo apt-get install openjdk-11-jdk
(Previously it installed openjdk-10, but not anymore)
To install Openjdk 11 in Ubuntu, the following commands worked well.
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt install openjdk-11-jdk
Do this to uninstall previous versions of openJDK on Ubuntu
Copysudo apt-get remove openjdk
To remove all of the config files and dependencies.
Copysudo apt-get purge --auto-remove openjdk*
Then install openJDK 11
Copysudo apt-get install openjdk-11-jdk
An upgrade will generally allow code compiled for Java 8 to run; but, there are some caveats.
The inclusion of Project JigSaw means that the access rules for "reaching" a method have changed slightly. They are almost compatible between Java 8 and Java 11. The differences will show when:
- You try to use one of the com.sun.* packages (or any other non-public api entry point).
- You try to use reflection on a non-public API entry point.
- You alter the launch to use a module, which will deactivate the Java 8 "default" module handling.
In short, it's almost an easy upgrade. The problems come into play when code is doing something it shouldn't have done, or when you have code not designed for modules, and some of your runtime code is designed for modules.
If you have access to source code, you can fix a lot of this by adding in the module specifications; but, that might require you to understand modularity (which is pretty easy, but a barrier nonetheless).
You can run this command and chose version java:
sudo update-alternatives --config java
This is what I do on my Debian system:
alias j8='export JAVA_HOME=/usr/lib/jvm/bellsoft-java8-full-amd64;export PATH=$JAVA_HOME/bin:$PATH'
This will ensure all executables are of the same version, and is a lot easier than update-alternatives, even if it did work (see my comments below another answer) or update-java-alternatives and is less error-prone