Learn how to completely remove Java from your Mac system
Keeping old Java versions installed on your Mac desktop or MacBook can lead to security vulnerabilities. Uninstalling Java from macOS might look intimidating—but the process is pretty easy, especially since we've included all the Terminal commands you need to complete the task.
Ways to Uninstall Java on Mac
- The best way to uninstall Java on macOS is via the Terminal, using the remove command.
- If you still have the installer for your version of Java, you can use it to uninstall Java.
- Use the Terminal to remove the JDK (if you have it) and the Java Deployment cache to fully uninstall Java from your system.
Steps
Section 1 of 4:
Via the Terminal
-
Ensure you have administrator privileges. Only administrators can uninstall Java via the Terminal. If you're using the first account created on your Mac, it's an administrator by default, so you can skip this step.
- Otherwise, you can add or remove administrators in the Users & Groups
section of an administrator account's System Settings.
- For a more in-depth guide on how to set your account as an administrator on Mac, check out this wikiHow article .
- Otherwise, you can add or remove administrators in the Users & Groups
section of an administrator account's System Settings.
-
Open the Terminal. There are a couple of ways you can do this:
- Click the magnifying glass in the upper-right corner and search for "Terminal."
- Open the Finder and go to Utilities > Terminal .
Advertisement -
Run the following commands. These commands should be run one at a time. To run them, copy and paste a command into your Terminal and press Return . Repeat this 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 you run a sudo command for the first time, the Terminal will ask for a password. Enter the password you use to login to your computer.
-
Close the Terminal. After all three commands have been run, you can exit the Terminal.
- If you have the Java Software Development Kit (JDK) installed, jump to this section to learn how to uninstall it.
- If you don't have the JDK installed, you can instead jump to this section to learn how to remove the Java Deployment cache.
Advertisement
Section 2 of 4:
Via the Installer
-
Open the Java installer. If you still have the Java installer on your Mac, you can use it to uninstall Java.
- If you have the most recent version of Java installed but don't still have the installer, you can download the installer from Java's website .
- However, if you have an older version of Java, running the installer may install the newer Java version alongside the older Java version instead of replacing it. If you have an old Java version, it's better to uninstall via the Terminal, explained above .
-
Enter your computer's admin password if prompted. If you've only ever had one account on your Mac, the first one you created is automatically an administrator.
- However, if you need to make your account an administrator, you can do so in the Users & Groups
section of an administrator account's System Settings.
- For a more in-depth guide on how to set your account as an administrator on Mac, check out this wikiHow article .
- However, if you need to make your account an administrator, you can do so in the Users & Groups
section of an administrator account's System Settings.
-
Click Remove . It's in the bottom-right corner of the "Welcome to Java" dialog box. Allow the uninstaller to finish processing before moving on.
-
Click the Apple menu and select System Settings… . If you're on an older version of macOS, you will see System Preferences… instead.
-
Look for the Java panel at the bottom of the sidebar. If you still see it, Ctrl+click on it and select "Remove Java Settings pane".
- After removing the Java Settings pane, you can exit your System Settings menu.
-
Click on the Finder, then navigate to Go > Go to Folder . Alternatively, you can press Cmd+Shift+G to open the Go to Folder window.
-
Go to the following locations and delete any remaining Java files or folders. Copy and paste each file path below into Go to Folder, look for any files or folders with "Java" in the name, and drag those files/folders to the Trash.
- /Library/Application Support/Oracle
- /Library/Java/
- /Library/Internet Plug-ins/
- /Library/PreferencePanes
-
Empty the Trash. Open the Trash folder on your desktop and empty it to fully delete any and all straggling Java files you found buried in your computer's directories.
- If you have the Java Software Development Kit (JDK) installed, jump to this section to learn how to uninstall it.
- If you don't have the JDK installed, you can instead jump to this section to learn how to remove the Java Deployment cache.
Advertisement
Section 3 of 4:
Uninstalling the JDK
-
Ensure you have administrator privileges. Only administrators can uninstall JDK. If you're using the first account created on your Mac, it's an administrator by default, so you can skip this step.
- Otherwise, you can add or remove administrators in the Users & Groups
section of an administrator account's System Settings.
- For a more in-depth guide on how to set your account as an administrator on Mac, check out this wikiHow article .
- Otherwise, you can add or remove administrators in the Users & Groups
section of an administrator account's System Settings.
-
Uninstall the Java Runtime Environment before uninstalling the JDK. We explain how to do this earlier in the article. Check out the first section to uninstall Java with the terminal and the second section to uninstall Java with the installer.
-
Open the Terminal. There are a couple of ways you can do this:
- Click the magnifying glass in the upper-right corner and search for "Terminal."
- Open the Finder and go to Utilities > Terminal .
-
Change the directory of the Terminal to your Java Virtual Machines folder. To do this, copy and paste the following command into the Terminal and hit Return . [1] X Research source
- cd /Library/Java/JavaVirtualMachines
-
Run a list command to see which versions of JDK you have installed (optional). If you know which JDK version you have installed, you can skip this step. If you aren't sure which JDK version(s) you have installed, copy and paste the following command into the Terminal and press Return :
- ls --directory *jdk*
- The Terminal will list all of your JDK versions in the format jdk-1.#.jdk , with the hashtag (#) being the number of your version.
- ls --directory *jdk*
-
Run a remove command to remove your desired JDK version(s). Copy and paste the command below into Terminal and press Return to run it. Make sure to replace the hashtag (#) with the JDK version number you want to remove.
- sudo rm -rf jdk-1.#.jdk
- After you run a sudo command for the first time, the Terminal will ask for a password. Enter the password you use to login to your computer.
- If you want to remove more than one JDK installation, add more JDK paths separated with a space. Just be sure to change the hashtag (#) to the correct version number.
- sudo rm -rf jdk-1.#.jdk
-
Run the Java command to ensure it's removed. Enter java into the Terminal and press Return . You should get an error that says "No Java runtime present, requesting install."
- If you don't get an error stating that Java is uninstalled, follow the steps in this guide again.
- Once Java and the JDK are uninstalled, continue to this section to learn how to remove the Java Deployment cache.
Advertisement
Section 4 of 4:
Removing the Java Deployment Cache
-
Ensure you have administrator privileges. If you're using the first account created on your Mac, it's an administrator by default, so you can skip this step.
- Otherwise, you can add or remove administrators in the Users & Groups
section of an administrator account's System Settings.
- For a more in-depth guide on how to set your account as an administrator on Mac, check out this wikiHow article .
- Otherwise, you can add or remove administrators in the Users & Groups
section of an administrator account's System Settings.
-
Open the Terminal. There are a couple of ways you can do this:
- Click the magnifying glass in the upper-right corner and search for "Terminal."
- Open the Finder and go to Utilities > Terminal .
-
Run the following command. Copy and paste the command below into the Terminal and press Return to run it and remove the Java Deployment cache. The Java Deployment cache stores various Java files and settings, but isn't always removed when you uninstall Java or JDK.
- sudo rm -r ~/"Library/Application Support/Oracle/Java"
- After you run a sudo command for the first time, the Terminal will ask for a password. Enter the password you use to login to your computer.
- sudo rm -r ~/"Library/Application Support/Oracle/Java"
Advertisement
Expert Q&A
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Tips
- If you see any Java tools files in the /usr/bin directory, don't remove them. These files are part of your Mac's system software, and they'll be reinstalled the next time you update your computer.Thanks
- While many programs have self-contained Java that they can use to run, some programs (and even websites) still need to use the Java Runtime Environment (JRE). To learn how to reinstall the newest version of Java, check out this wikiHow article .Thanks
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
Advertisement
About This Article
Thanks to all authors for creating a page that has been read 3,376 times.
Advertisement