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.
Answer from Danila Zharenkov on Stack OverflowFrom 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

macos - How to remove OpenJDK and go back to regular JDK - Ask Different
How to uninstall Java
java - uninstall openjdk in mac - Stack Overflow
Uninstall AdoptOpenJDK from Mac
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.