Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove default-jre java installation from Ubuntu?

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?

like image 915
John Little Avatar asked May 30 '14 16:05

John Little


3 Answers

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.

like image 165
Nishant Bhakta Avatar answered Oct 03 '22 21:10

Nishant Bhakta


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
like image 29
Kshitij Avatar answered Oct 03 '22 20:10

Kshitij


sudo apt-get remove default-jre

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

like image 27
Bary12 Avatar answered Oct 03 '22 20:10

Bary12