Steps I performed were from here : https://www.java.com/en/download/help/mac_uninstall_java.html
In the Terminal window Copy, Paste and run the commands below (one by one) :
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane sudo rm -fr ~/Library/Application\ Support/Oracle/JavaThen after successfully uninstalling Java, you may remove Java Deployment cache: In the Terminal window Copy and Paste the commands below:
rm -r ~/"Library/Application Support/Oracle/Java"then remove the jdk folder and it's content:
sudo rm -r -f /Library/Java/JavaVirtualMachines/jdk<"your_version">.jdkthen perform the holy computer restart .
If you have more than 1 java version installed you may also find useful the info from this page: https://java.tutorials24x7.com/blog/how-to-switch-java-version-on-mac
Answer from user18091415 on Stack OverflowSteps I performed were from here : https://www.java.com/en/download/help/mac_uninstall_java.html
In the Terminal window Copy, Paste and run the commands below (one by one) :
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane sudo rm -fr ~/Library/Application\ Support/Oracle/JavaThen after successfully uninstalling Java, you may remove Java Deployment cache: In the Terminal window Copy and Paste the commands below:
rm -r ~/"Library/Application Support/Oracle/Java"then remove the jdk folder and it's content:
sudo rm -r -f /Library/Java/JavaVirtualMachines/jdk<"your_version">.jdkthen perform the holy computer restart .
If you have more than 1 java version installed you may also find useful the info from this page: https://java.tutorials24x7.com/blog/how-to-switch-java-version-on-mac
You can try removing Java from your system with these commands
rm will remove the specified file or directory.
options -r If it's a directory, it will remove all its contents recursively, including subdirectories/files and their contents. -f Do this forcefully without asking for confirmation for each files and folders.
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk[version].jdk
Example:
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-17.jdk
Additional Files/Folders
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf ~/Library/Application\ Support/Oracle/Java
From the official Oracle manual.
Navigate to
/Library/Java/JavaVirtualMachinesand remove the directory whose name matches the following format:/Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdkFor example, to uninstall 8u6:
%rm -rf jdk1.8.0_06.jdkDo not attempt to uninstall Java by removing the Java tools from
/usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.
To remove system files you need to add sudo before rm -rf command.
For MacOS - Big Sur | Using Terminal
I was able to remove OpenJDK as per information provided in below link.
Site Link

How to uninstall Java
How to uninstall jdk 17 on mac? - Oracle Forums
macos - How to uninstall java from mac completely? JRE and JDK - Stack Overflow
macos - How to remove OpenJDK and go back to regular JDK - Ask Different
Videos
I installed several versions of the JDK, both official and open source. But I no longer need them. How exactly do you "uninstall" Java on macOS?
The best I can figure is just to go into HD/Library/Java and just delete everything there. Slightly new to macOS so wondering if this is right. The installers themselves don't give any means of uninstalling.
To uninstall AdoptOpenJDK installed via Homebrew,
brew uninstall adoptopenjdk8
To uninstall OpenJDK installed via Homebrew,
brew uninstall openjdk8
The /usr/bin/java and other related tools are macOS shims that run a specific version of Java, as defined by the JAVA_HOME variable.
This variable is usually set in your ~/.bashrc file:
export JAVA_HOME=$(/usr/libexec/java_home -v1.8)`
You can check the current value:
$ echo $JAVA_HOME
/usr/local/Cellar/openjdk@8/1.8.0-392/libexec/openjdk.jdk/Contents/Home
You may have multiple versions of Java installed, to list them all:
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
21.0.1 (x86_64) "Homebrew" - "OpenJDK 21.0.1" /usr/local/Cellar/openjdk/21.0.1/libexec/openjdk.jdk/Contents/Home
17.0.9 (x86_64) "Homebrew" - "OpenJDK 17.0.9" /usr/local/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home
1.8.0_392 (x86_64) "Homebrew" - "OpenJDK 8" /usr/local/Cellar/openjdk@8/1.8.0-392/libexec/openjdk.jdk/Contents/Home
/usr/local/Cellar/openjdk/21.0.1/libexec/openjdk.jdk/Contents/Home
In my case, you can see there are three versions of OpenJDK installed via homebrew. I can look them up in the list of installed packages:
$ brew list | grep -iE 'java|jdk|temurin'
openjdk
openjdk@17
openjdk@8
If I wanted to remove all of them, I could do brew uninstall them one by one, or:
$ for pkg in $(brew list | grep -iE 'java|jdk|temurin'); do brew uninstall $pkg; done