How to uninstall Java from Mac OS

Uninstall Java from MacOS step-by-step guide.

Start by opening terminal window in your Mac, and executing the following command to get currently installed version of Java.

java --version

If you have Java Installed on your system you will should get output that look similar to the one below.

java 20 2023-03-21
Java(TM) SE Runtime Environment (build 20+36-2344)
Java HotSpot(TM) 64-Bit Server VM (build 20+36-2344, mixed mode, sharing)

If Java is not present on your system, you will get the following output.

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit for information on installing Java.

Once you have confirmed that you have Java on your system you can go ahead and complete the steps below to un install it.

First you need to find the installation directory. Default directory on Mac OS is “/Library/Java/JavaVirtualMachines”. Just to be sure run the following command to confirm.

/usr/libexec/java_home -V

The output you get should look similar to the one below. As you can see on my system I have Java 20 and Java 17. Yours may, or may not look the same. Regardless of what version you have here you will be able to see the installation path “/Library/Java/JavaVirtualMachines/”.

Matching Java Virtual Machines (2):
    20 (x86_64) "Oracle Corporation" - "Java SE 20" /Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home
    17.0.6 (x86_64) "Oracle Corporation" - "Java SE 17.0.6" /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home

To remove Java all you have to do is run the following command, replace the version number with the one you would like to remove from your system, when prompted enter your password.

sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-17.jdk

In the example above Java 17 will be removed from the system, to remove Java 20 replace “jdk-17.jdk” with “jdk-20.jdk”.

WARNING: Do not attempt to uninstall Java by removing the Java tools from “/usr/bin” !!!