For me it was:

sudo apt-get remove openjdk-6*
sudo apt-get remove icedtea*
Answer from DavidGamba on Stack Exchange
Top answer
1 of 3
11

For me it was:

sudo apt-get remove openjdk-6*
sudo apt-get remove icedtea*
2 of 3
3

I came across this because I am working through an instructional book for android programming which wants to use a specific Java SE and JRE (8u121) and requests that all other java packages be removed before continuing with the installation. So after reading the above ideas I went with:

sudo apt-get remove openjdk*

and the result was:

bryan@kali:~$ java -version
bash: /usr/bin/java: No such file or directory

So the above suggests that there is no java found of any version. Which is the OP wanted to do (I think).

In case somebody finds this thread because they are uninstalling Java so that they can install an Old Version, I have included a walk-through I found. The first two codes help you install it if you had no GUI. If you have a tarball then skip those. The last codeblock has some parts that you'll need to edit if you are not installing my same version.


{begin copy/paste}

In case that you are attempting to install Java JDK remotely and have absolutely no access to Graphical User Interface and web browser use the following curl method to download Java JDK using a command line.

First, obtain a correct download URL by using the curl command:

$ curl -s http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html | grep "otn-pub" | cut -d \" -f12

The above command outputs a bunch of URLs for your selection. To initiate the download of the desired Java file, copy its URL and start the download using the curl command while accepting the requested Jave license. For example:

$ curl -LOb "oraclelicense=a" http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz

Install Java JDK At this stage, we should have an appropriate Java JDK tarball within our current working directory:

$ ls
jdk-8u121-linux-x64.tar.gz

Create a target Java JDK installation directory:

# mkdir /opt/java-jdk

Extract the previously downloaded Java JDK tarball:

# tar -C /opt/java-jdk -zxf jdk-8u121-linux-x64.tar.gz

Set Oracle Java as default Currently, the system does not recognise our Java JDK installation:

$ update-alternatives --list java
update-alternatives: error: no alternatives for java
$ java
bash: java: command not found

Use the update-alternatives command to inlcude both, java and javac as part of the system's Java environment.Please replace the below path to java binaries where appropriate to reflect your downloaded java version:

# update-alternatives --install /usr/bin/java java /opt/java-jdk/jdk1.8.0_121/bin/java 1   
update-alternatives: using /opt/java-jdk/jdk1.8.0_121/bin/java to provide /usr/bin/java (java) in auto mode
# update-alternatives --install /usr/bin/javac javac /opt/java-jdk/jdk1.8.0_121/bin/javac 1
update-alternatives: using /opt/java-jdk/jdk1.8.0_121/bin/javac to provide /usr/bin/javac (javac) in auto mode

{end copy/paste}

Okay so after I followed that I wanted to confirm that it works...

bryan@kali:~/Desktop$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

That's it! That's what we want.

Then I became concerned that it 'apt update' may just undo what I did by updating the package (unsure). So I put them on hold. To remove hold: apt-mark unhold.

bryan@kali:~/Desktop$ sudo apt-mark hold openjdk-8*
openjdk-8-jre set on hold.
openjdk-8-jre-headless set on hold.
openjdk-8-doc set on hold.
openjdk-8-jdk set on hold.
openjdk-8-dbg set on hold.
openjdk-8-demo set on hold.
openjdk-8-jdk-headless set on hold.
openjdk-8-source set on hold.
openjdk-8-jre-dcevm set on hold.
openjdk-8-jre-zero set on hold.
🌐
Oracle
java.com › en › download › help › uninstall_java.html
How do I uninstall Java on my Windows computer?
Platform(s): Windows 10, Windows 8, Windows 7, Windows XP, Windows 11 · Windows Users: Improve the security of your computer by checking for old versions of Java and removing them when you install Java 8 (8u20 and later versions) or by using the Java Uninstall Tool.
Discussions

how to uninstall Java from windows 10
I had recently installed Java (JavaSetup8u171) on my computer running windows 10. I needed it to be able to install a driver for nvidia drivers and now I do not need the java installed on my computer (though I could be wrong). if possible how do I… More on learn.microsoft.com
🌐 learn.microsoft.com
3
120
June 14, 2018
linux - How to remove old version of Java and install new version - Stack Overflow
I have a Linux box on which Java 1.7 is installed: #java -version java version "1.7.0_09-icedtea" OpenJDK Runtime Environment (rhel-2.3.4.1.el6_3-x86_64) OpenJDK 64-Bit Server VM (build 23.2-b09, ... More on stackoverflow.com
🌐 stackoverflow.com
how to delete java completely from windows - Stack Overflow
I have messed up my windows java installation and i want to delete everything and re-install java , all of my java versions have been messed up and I don't know what to do in this situation when I ... More on stackoverflow.com
🌐 stackoverflow.com
help me uninstall java that is installed and work but not uninstallable by apt or snap???
[...] sudo apt purge OpenJDK [...] Linux is very, very case sensitive :-) Also, the command should be: sudo apt remove --purge openjdk <--- IF you installed it from a .deb package also see "sudo apt search openjdk" for a list of all the available packages which contain the "openjdk" string. sudo snap remove openjdk <--- IF you installed it as a snap also see "sudo snap list" and "sudo snap search openjdk" More on reddit.com
🌐 r/Ubuntu
3
1
October 29, 2024
🌐
Ultimate Systems Blog
blog.usro.net › ultimate systems blog › how-to › linux › how to uninstall java from debian
How to Uninstall Java from Debian – Ultimate Systems Blog
October 27, 2024 - Sometimes, we need to clean up our systems or simply remove software we no longer use. If you’re ready to say goodbye to Java on your Debian system, uninstalling it is straightforward. This guide covers everything from uninstalling a single version to removing multiple versions and cleaning up any lingering files.
🌐
Oracle
java.com › en › download › uninstalltool.jsp
Java Uninstall Tool for macOS
» Troubleshoot Java » Instructions for Uninstalling Java » Request Uninstall Help » Other help · If you are experiencing issues while uninstalling Java, please see the Java uninstall instructions. If you are still having trouble uninstalling out-of-date versions of Java, you can request ...
🌐
javaspring
javaspring.net › blog › how-to-uninstall-java
How to Uninstall Java: A Comprehensive Guide — javaspring.net
This includes the Java Runtime Environment (JRE), the Java Development Kit (JDK), and any related environment variables. Open the Control Panel. You can do this by searching for "Control Panel" in the Windows search bar.
Top answer
1 of 5
28
  1. To remove OpenJDK (the one you've already installed)

    sudo apt-get purge openjdk-\*

  2. Make a new directory for your new JDK

    sudo mkdir -p /usr/local/java

  3. Copy the file to the directory (you should be in that file path)

    sudo cp -r jdk-8u45-linux-x64.tar.gz /usr/local/java/

  4. Extract the file

    sudo tar xvzf jdk-8u45-linux-x64.tar.gz

  5. You should add this to your PATH now. To do that:

    a. Open /etc/profile : sudo gedit /etc/profile

    b. Scroll down (the end) and add the path where your jdk was installed

    JAVA_HOME=/usr/local/java/jdk1.8.0_45 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin export JAVA_HOME export PATH

    Save and exit

  6. Inform your Linux system where your Oracle Java JDK/JRE is located.

    a. Notify the system that Oracle Java JRE is available for use

    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_45/bin/java" 1

    b. Notify the system that Oracle Java JDK is available for use

    sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_45/bin/javac" 1

    c. Notify the system that Oracle Java Web start is available for use

    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_20/bin/javaws" 1

  7. Inform your Linux system that Oracle Java JDK/JRE must be the default Java.

    a. Set the java runtime environment for the system

    sudo update-alternatives --set java /usr/local/java/jdk1.8.0_45/bin/java

    b. Set the javac compiler for the system

    sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_45/bin/javac

    c. Set Java Web start for the system

    sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_20/bin/javaws

  8. Reload your system wide PATH

    source /etc/profile

  9. Check the new version and you're done!

    java -version

2 of 5
8

Just unpack the new Java version, for example into /opt. Then do

Copyexport JAVA_HOME=/opt/jdk1.8.0_45 
export PATH=$JAVA_HOME/bin:$PATH

Put these exports into the startup files for your shell and you should be set. It is not necessary to uninstall the Java 7 installation.

Find elsewhere
🌐
Oracle
java.com › en › uninstall › uninstall_instructions.html
Uninstall instructions for Java
You can uninstall Java in the same way as you would uninstall any other software from your computer. You may need administrator privileges to remove programs. Java may appear in the program list as J2SE, Java 2, Java SE or Java Runtime Environment. Click on the Windows icon at bottom-left corner ...
🌐
MakeUseOf
makeuseof.com › home › linux › how to install java on ubuntu and remove it when you’re done
How to Install Java on Ubuntu and Remove It When You’re Done
February 23, 2023 - To remove OpenJDK and OpenJRE, launch the terminal using Ctrl + Alt + T and issue the following command to remove Java from your system: ... Confirm the uninstallation process by typing y.
🌐
Oracle
java.com › en › download › help › uninstaller_toolfaq.html
Information about the Java Uninstall Tool for Windows
Operating system: Windows Windows Vista, Windows 7, Windows 8, Windows 10, Windows Server 2008 R2, Windows Server 2012 Browsers: Not browser specific Java version: Can remove Java versions 1.4.2 and above. Does not require Java to run the tool. Other: Tool must be run online - see note · Java Uninstall Tool Update.
🌐
Oracle
java.com › en › download › help › linux_uninstall.html
How do I uninstall Java for Linux?
There are two ways to uninstall Java. Please use the method that you used when you installed Java.
🌐
Azul
docs.azul.com › core › uninstall › other-distributions
Uninstalling other OpenJDK distributions
# Check all the installed packages $ sudo apt list --installed # Uninstall example, depending on the installed package, for example 'openjdk-17-jre' $ sudo apt remove openjdk-17-jre # To remove the package including all its files and configuration files, instead use $ sudo apt purge openjdk-17-jre ...
🌐
Linux Hint
linuxhint.com › uninstall-java-on-windows10
Linux Hint – Linux Hint
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Tutorials24x7
java.tutorials24x7.com › blog › how-to-uninstall-java-from-windows
How To Uninstall Java From Windows | Tutorials24x7
May 2, 2020 - Click the Uninstall Button to remove the JRE 8 from Windows 10. It will uninstall JRE 8 and update the applications list as shown in Fig 6 and Fig 7. ... Similarly, uninstall JDK 8 to completely uninstall Java 8 from Windows 10.
🌐
Java Code Geeks
examples.javacodegeeks.com › home › java development › core java
How to Uninstall Java for Windows 10 - Java Code Geeks
September 25, 2020 - We will look at how to uninstall and remove Java completely from a Windows 10 system through tools. Invented by James Gosling, Java is an extremely
🌐
MajorGeeks
majorgeeks.com › tutorials and video guides › three ways to remove or update older versions of java
Three Ways to Remove or Update Older Versions of Java - MajorGeeks
November 20, 2022 - There are numerous ways to update or remove Java: 1: The quickest way to uninstall Java is in your Settings or Control Panel. Windows 10 - Click Start > Settings > Apps. Click on the Java you'd like to uninstall and click on Uninstall.
🌐
Stack Overflow
stackoverflow.com › questions › 70571066 › how-to-delete-java-completely-from-windows
how to delete java completely from windows - Stack Overflow
I'm not sure how to fix the issue regarding it being open elsewhere but I'd recommend trying to open task manager to close Java that way. As for uninstalling it, you can uninstall it as it is an app.
🌐
Oracle
java.com › en › download › help › regkey_addremove.html
After uninstalling Java, how do I remove its listing in the Windows Uninstall/Remove Programs?
After you finish above steps, go back to the Windows Control Panel Windows XP: Add or Remove Programs Windows 7, Windows 8, Windows 10: Uninstall a program The entry for Java should no longer appear.
🌐
Novice Stuffs
novicestuffs.wordpress.com › 2017 › 04 › 25 › how-to-uninstall-java-from-linux
How To Uninstall JDK From Linux ? – Novice Stuffs
December 28, 2017 - This tutorial is written to help New Linux Users, who want to uninstall Java Development Kit (JDK) installed on their Linux. The tasks performed on Ubuntu 16.04, but this will also work on other Debian Based Linux like Linux Mint, Kali Linux, etc. So, first of all, check the vendor of the JDK you have…