how to remove default-jre java installation from Ubuntu?

To completely remove jdk from your system, follow these below steps:

  1. Type sudo apt-get autoremove default-jdk openjdk- (Don't hit Enter right now).
  2. Now press tab button for 2 or 3 times, you will get list of packages starting with openjdk-.
  3. Look for name like openjdk-11-jdk. You need to get java version, here is 11.
  4. Now complete your command to sudo apt-get autoremove default-jdk openjdk-11-jdk. (Change 11 to your java version)
  5. And Hit Enter button.

Now you have done removing java from your system.


sudo apt-get remove default-jre

removes the package "default-jre". all tho you should ask in askUbuntu


To set the Java version interactively:

Log in as root or use sudo.

View the Java alternatives.

$ update-alternatives --config java

This command lists the Java installations and prompts to select from the choices.

Sample response

There are 4 programs which provide 'java'.

Selection Command


1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

2 * /usr/lib/jvm/zulu-6/bin/java

3 /usr/lib/jvm/zulu-7/bin/java

4 /usr/lib/jvm/zulu-8/bin/java

Select a Java version, at the prompt, type a number.

Press enter to keep the default[*], or type selection number:

Sample response

Using '/usr/lib/jvm/zulu-7/bin/java' to provide 'java'.

Verify the switch, check the Java version.

$ java -version

Sample response

openjdk version "1.7.0_65"

OpenJDK Runtime Environment (Zulu 7.6.0.1-linux64) (build 1.7.0_65-b17)

OpenJDK 64-Bit Server VM (Zulu 7.6.0.1-linux64) (build 24.65-b04, mixed mode)

To set the Java version by path:

Log in as root or use sudo.

Specify the path to use when running Java.

$ update-alternatives --set java /usr/lib/jvm/zulu8/bin/java

Bary12's answer worked for me:

sudo apt-get autoremove default-jre