Follow this guide to fully remove Java from your Mac system.
Having outdated Java versions on your Mac desktop or MacBook could pose security risks. While removing Java from macOS might seem daunting, it’s actually simple—especially with the included Terminal commands to guide you through the process.
Methods to Uninstall Java on Mac
- The most effective way to remove Java from macOS is through Terminal, using the remove command.
- If you have the original installer for your Java version, you can use it to uninstall Java.
- To completely remove Java from your system, use Terminal to delete the JDK (if installed) and the Java Deployment cache.
Uninstallation Steps
Using the Terminal

Make sure you have administrator privileges. Only users with administrator access can uninstall Java through the Terminal. If you’re using the first account created on your Mac, it’s automatically an administrator, so you can skip this step.
- If not, you can add or remove administrators in the Users & Groups section of an admin account’s System Settings.
- For a detailed guide on how to make your account an administrator on Mac, refer to this Mytour article.

Launch the Terminal. You have several ways to do this:
- Click the magnifying glass in the top-right corner and search for "Terminal."
- Open Finder, then navigate to Utilities > Terminal.

Execute the following commands. These commands should be entered one by one. To run each, copy and paste the command into the Terminal and press Return. Repeat this process for all three commands.
- sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
- sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
-
sudo rm -fr ~/Library/Application\ Support/Oracle/Java
- After running the first sudo command, Terminal will prompt you for a password. Enter your login password to proceed.

Exit the Terminal. Once all three commands have been executed, you can close the Terminal.
- If you have the Java Software Development Kit (JDK) installed, go to this section for instructions on how to uninstall it.
- If the JDK isn’t installed, proceed to this section to learn how to remove the Java Deployment cache.
Using the Installer

Launch the Java installer. If the Java installer is still available on your Mac, you can use it to remove Java.
- If you have the latest version of Java but no longer have the installer, you can download it from Java's website.
- If you have an older version of Java, running the installer may install the latest version alongside the old one instead of replacing it. In this case, it’s recommended to uninstall via the Terminal, as described above.

Enter your Mac’s administrator password if asked. If you’ve only had one account on your Mac, the first one you created is automatically an administrator.
- If you need to grant your account admin privileges, you can do so in the Users & Groups section of an administrator account’s System Settings.
- For detailed instructions on making your account an administrator, visit this Mytour article.

Click the Remove. This option appears in the bottom-right corner of the "Welcome to Java" dialog box. Allow the uninstallation process to complete before proceeding.

Click the Apple menu and choose System Settings…. On older macOS versions, you’ll find System Preferences… instead.

Look for the Java section at the bottom of the sidebar. If it's still there, Ctrl+click on it and choose "Remove Java Settings pane".
- After removing the Java Settings pane, you can close your System Settings menu.

Click on Finder, then go to Go > Go to Folder. Alternatively, use Cmd+Shift+G to open the Go to Folder window.

Navigate to the following locations and remove any leftover Java files or folders. Paste each of the file paths into the Go to Folder, search for any Java-related files or folders, and drag them to the Trash.
- /Library/Application Support/Oracle
- /Library/Java/
- /Library/Internet Plug-ins/
- /Library/PreferencePanes

Empty the Trash. Open your Trash folder and empty it to permanently delete all the Java files you found hidden in your system directories.
- If you have the Java Software Development Kit (JDK) installed, proceed to this section for instructions on how to uninstall it.
- If the JDK is not installed, proceed to this section to learn how to clear the Java Deployment cache.
Removing the JDK

Verify that you have administrator privileges. Only administrators can remove the JDK. If you're using the first account created on your Mac, it’s an administrator account by default, and you can skip this step.
- If you need to make your account an administrator, you can do so in the Users & Groups section within an admin account’s System Settings.
- If you need further guidance on how to set your account as an administrator, you can refer to this Mytour article.

Uninstall the Java Runtime Environment before removing the JDK. You’ll find instructions for this earlier in the article. To uninstall Java using the terminal, refer to the first section, and to uninstall via the installer, check out the second section.

Launch the Terminal. There are several ways to open it:
- Click the magnifying glass in the upper-right corner and type "Terminal" to find it.
- Open Finder and navigate to Utilities > Terminal.

Navigate to your Java Virtual Machines folder in the Terminal. To do so, copy and paste the following command into the Terminal and hit Return.
- cd /Library/Java/JavaVirtualMachines

Run a list command to check which JDK versions are installed (optional). If you already know which version(s) of JDK you have, you can skip this step. If you're unsure, copy and paste the following command into the Terminal and press Return:
- ls --directory *jdk*
- The Terminal will display all your installed JDK versions, listed as jdk-1.#.jdk, where the # represents your version number.

Execute a command to uninstall your selected JDK version(s). Copy the following command into Terminal and press Return. Be sure to replace the hashtag (#) with the correct version number of the JDK you wish to remove.
- sudo rm -rf jdk-1.#.jdk
- When running a sudo command for the first time, you will be prompted for your computer's login password.
- If you're removing multiple JDK versions, simply separate the JDK paths with spaces, making sure to replace the hashtag (#) with the correct version number.

Use the Java command to verify its removal. Type java in Terminal and hit Return. You should see an error message saying "No Java runtime present, requesting install."
- If you don’t see this error, follow the steps in this guide again to ensure complete uninstallation.
- Once Java and JDK are removed, proceed to this section for instructions on clearing the Java Deployment cache.
Clearing the Java Deployment Cache

Confirm you have administrator access. If you’re using the original account on your Mac, it’s automatically an administrator, so you can skip this step.
- If not, you can manage administrator accounts through the Users & Groups section in System Settings of an admin account.
- For a detailed guide on setting up your account as an administrator, refer to this Mytour article.

Launch the Terminal. There are multiple ways to access it:
- Click the magnifying glass in the upper-right corner of your screen and search for "Terminal."
- Open Finder and navigate to Utilities > Terminal.

Execute the following command. Copy and paste the command below into the Terminal, then press Return to run it. This will remove the Java Deployment cache, which contains various Java files and settings that aren't always removed when Java or JDK is uninstalled.
- sudo rm -r ~/"Library/Application Support/Oracle/Java"
- Upon running the sudo command for the first time, you will be prompted for your computer’s password. Enter the same password used to log in.
-
If you find any Java tools files in the /usr/bin directory, avoid deleting them. These are essential parts of your Mac’s system software and will be reinstalled when you update your computer.
-
Although many applications come with their own version of Java, some programs (and websites) still rely on the Java Runtime Environment (JRE). To reinstall the latest version of Java, refer to this Mytour article.
