0

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)?

Vipul Tyagi
  • 547
  • 3
  • 11
  • 29

2 Answers2

6

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

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:

  1. You try to use one of the com.sun.* packages (or any other non-public api entry point).
  2. You try to use reflection on a non-public API entry point.
  3. 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).

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138