I have JDK 8 installed in my ubuntu 18.04 system and I now want to upgrade it to JDK 11 using this. I just want to know if this would create any problem or not. Would the older version be removed on upgrading( Actually I want older version to be removed by itself)?
2 Answers
Do this to uninstall previous versions of openJDK on Ubuntu
sudo apt-get remove openjdk
To remove all of the config files and dependencies.
sudo apt-get purge --auto-remove openjdk*
Then install openJDK 11
sudo apt-get install openjdk-11-jdk

- 1,328
- 13
- 20
-
Why you didn't use purge command? – Vipul Tyagi Sep 02 '20 at 05:41
-
Purge would remove it along with the dependencies and configuration files, if you want that I'll add it to the answer now. – Favour Felix Chinemerem Sep 02 '20 at 05:42
-
Which one should I use?? – Vipul Tyagi Sep 02 '20 at 05:45
-
It is showing unable to locate package openjdk! – Vipul Tyagi Sep 02 '20 at 05:48
-
Assuming you are a developer, I would recommend SDKMAN (https://sdkman.io/). It helps you to download, install and select among different versions of JDK, among other things. – Sep 02 '20 at 05:48
-
You can use the one with `purge` command. – Favour Felix Chinemerem Sep 02 '20 at 05:48
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).

- 69,361
- 7
- 100
- 138