1

I tried several ways to install openjdk and here is what I get when I do: java -version

openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode, sharing)

But when I do javac -version, it says javac cannot be found. I do the following: sudo apt-get install default-jre

The following packages have unmet dependencies:
 default-jre : Depends: default-jre-headless (= 2:1.10-63ubuntu1~02) but 2:1.11-68ubuntu1~18.04.1 is to be installed
               Depends: openjdk-11-jre but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Then: sudo apt-get install default-jdk

default-jdk : Depends: default-jre (= 2:1.10-63ubuntu1~02) but it is not going to be installed
              Depends: default-jdk-headless (= 2:1.10-63ubuntu1~02) but it is not going to be installed
              Depends: openjdk-11-jdk but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Then: sudo update-alternatives --config java

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

How do I fix these issues and have a proper installation of java and javac?

1 Answers1

0

I was able to mitigate this issue by downloading the required version in the error message. In my case, I downloaded and installed the openjdk-11-jdk_11.0.9.1+1-0ubuntu1~18.04_amd64.deb and all its required dependencies from here: https://ubuntu.pkgs.org/18.04/ubuntu-updates-main-amd64/openjdk-11-jdk_11.0.9.1+1-0ubuntu1~18.04_amd64.deb.html.