how to remove default-jre java installation from Ubuntu?
Asked Answered
B

7

14

I had no java (i.e. 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 - i.e. id didnt uninstall java.

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

Bone answered 30/5, 2014 at 16:48 Comment(1)
askubuntu.com/questions/84483/how-to-completely-uninstall-java check the answer with bounty :)Wenda
T
11
sudo apt-get remove default-jre

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

Trove answered 30/5, 2014 at 16:49 Comment(13)
Just tried this. it now says "package default-jre is not installed", but java still is working.Bone
says "package default-jre is not installed", but java still is workingBone
try this: sudo apt-get remove openjdk-6-jreTrove
I am amazed apt-get does not have a way of listing installed packages. I just tried your suggestion, and it proceded to do a lot of deleting stuff, and bizarrely, its also saying "the following extra packages will be installed: icedtea-70jre0jamvm...openjdk-7-jre-headless....Bone
After the remove did pages of stuff, when I try java -version, I get back "java version 1.6.0_21" and it says openJDK runtime. so unistalling again had no effect.Bone
If I say sudo apt-get remove openjdk-6-jre again, it now says not installed., but java still is.Bone
reinstall default-jre and then:sudo apt-get autoremove default-jreTrove
interestingly, if I do "ls -l /usr/lib/jvm" I see lots of weid and wonderful java versions already there. E.g. java-1.7.0-openjdk-amd64 I wonder if the problem was that java was already on the box, but not correctly setup (so java command did not find java). If this is the case, how do I switch to the 1.7 java?Bone
take a look at thisTrove
Just tried "sudo apt-get autoremove default-jre". Says pakcage default-jre is not installed, so not removed, but they says the following packages will be removed: icedtea-netx-common, thunderbird-globalmenu Java -version still returns 1.6.0_13Bone
Wow this worked: sudo update-alternatives --config javaBone
Out of interest, how did you highlight the commands in your comments?Bone
when you post a comment there is a yellow highlight under the text box that tells you how.Trove
P
40

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.

Perionychium answered 9/5, 2018 at 5:38 Comment(2)
Thank You. Saved my day!Pretension
For me, I needed to remove openjdk-11-jre too so that I removed Java entirely from my system.Maloy
T
11
sudo apt-get remove default-jre

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

Trove answered 30/5, 2014 at 16:49 Comment(13)
Just tried this. it now says "package default-jre is not installed", but java still is working.Bone
says "package default-jre is not installed", but java still is workingBone
try this: sudo apt-get remove openjdk-6-jreTrove
I am amazed apt-get does not have a way of listing installed packages. I just tried your suggestion, and it proceded to do a lot of deleting stuff, and bizarrely, its also saying "the following extra packages will be installed: icedtea-70jre0jamvm...openjdk-7-jre-headless....Bone
After the remove did pages of stuff, when I try java -version, I get back "java version 1.6.0_21" and it says openJDK runtime. so unistalling again had no effect.Bone
If I say sudo apt-get remove openjdk-6-jre again, it now says not installed., but java still is.Bone
reinstall default-jre and then:sudo apt-get autoremove default-jreTrove
interestingly, if I do "ls -l /usr/lib/jvm" I see lots of weid and wonderful java versions already there. E.g. java-1.7.0-openjdk-amd64 I wonder if the problem was that java was already on the box, but not correctly setup (so java command did not find java). If this is the case, how do I switch to the 1.7 java?Bone
take a look at thisTrove
Just tried "sudo apt-get autoremove default-jre". Says pakcage default-jre is not installed, so not removed, but they says the following packages will be removed: icedtea-netx-common, thunderbird-globalmenu Java -version still returns 1.6.0_13Bone
Wow this worked: sudo update-alternatives --config javaBone
Out of interest, how did you highlight the commands in your comments?Bone
when you post a comment there is a yellow highlight under the text box that tells you how.Trove
P
5

Bary12's answer worked for me:

sudo apt-get autoremove default-jre

Paraffinic answered 6/7, 2017 at 13:34 Comment(2)
How is this an answer? It's a comment.Galvani
worked for me, thats simplest answerFruitless
B
3

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
Bellwort answered 21/10, 2020 at 13:18 Comment(1)
This actually helped me. doing sudo apt insstall default-jre was telling me I had the most recent version but I wasnt getting openjdk version <version> when doing java -version. I just changed the option in update-alternatives to the path containg the java version I wanted (Java 11 in my case)Coplin
H
2

It may be useful for you. firtstly,use this command to show all the jdk of installed.

dpkg -l | grep -i jdk

Secondly,use this command to uninstall the jdk.

sudo apt purge <package_name>
Heilbronn answered 12/9, 2023 at 7:47 Comment(0)
T
1

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
Tartuffery answered 17/6, 2019 at 6:42 Comment(0)
J
1

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  
Jodyjoe answered 16/11, 2022 at 11:48 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.