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?
To completely remove jdk from your system, follow these below steps:
sudo apt-get autoremove default-jdk openjdk-
(Don't hit Enter
right now).tab
button for 2 or 3 times, you will get list of packages
starting with openjdk-
.openjdk-11-jdk
. You need to get java version,
here is 11.sudo apt-get autoremove default-jdk
openjdk-11-jdk
. (Change 11 to your java version)Enter
button.Now you have done removing java from your system.
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
sudo apt-get remove default-jre
removes the package "default-jre". all tho you should ask in askUbuntu
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With