简体   繁体   中英

how to remove default-jre java installation from Ubuntu?

I had no java (ie java -version said java no found or similar)

I installed it like this:

sudo apt-get install default-jre

This results in installing java 1.6 - I need java 1.7

So the next probelem is how to uninstall it.

I tried this:

sudo apt-get --purge -remove default-jre

Which seemed to work, but when I do:

java -version

I still java respond with 1.6 - ie id didnt uninstall java.

Ok, so I guess -remove does not remove the thing it installed. Is there a way to o this?

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

Bary12's answer worked for me:

sudo apt-get autoremove default-jre

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

I Installed Default JDK like this

sudo apt install -y default-jdk

Removed like this

sudo apt remove openjdk-11-jre-headless openjdk-11-jre openjdk-11-jdk-headless openjdk-11-jdk  

You can remove Java 12 using this command--

sudo apt-get remove oracle-java12-installer

you can change the version by changing the 12 to the version present on your computer

then recheck by finding version -

java -version

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM