How to recover `/usr/lib/jvm` in Ubuntu? [duplicate]

I accidentally deleted /usr/lib/jvm through the terminal.

How can I fix this problem?


Solution 1:

First let's see which package(s) provided the files in that directory:

$ dpkg -S /usr/lib/jvm
openjdk-8-jre-headless:amd64, default-jre-headless: /usr/lib/jvm

(please check on your own system - the exact packages may be different)

Then reinstall those packages (replace with your own results):

sudo apt install --reinstall openjdk-8-jre-headless:amd64 default-jre-headless

Now /usr/lib/jvm is back