PDF download Download Article
Learn how to completely remove Java from your Mac system
PDF download Download Article

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.
Section 1 of 4:

Via the Terminal

PDF download Download Article
  1. 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 .
  2. 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
  3. 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.
  4. After all three commands have been run, you can exit the Terminal.
  5. Advertisement
Section 2 of 4:

Via the Installer

PDF download Download Article
  1. 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 .
  2. 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 .
  3. It's in the bottom-right corner of the "Welcome to Java" dialog box. Allow the uninstaller to finish processing before moving on.
  4. If you're on an older version of macOS, you will see System Preferences… instead.
  5. 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.
  6. Alternatively, you can press Cmd+Shift+G to open the Go to Folder window.
  7. 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
  8. 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.
  9. Advertisement
Section 3 of 4:

Uninstalling the JDK

PDF download Download Article
  1. 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 .
  2. 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.
  3. 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 .
  4. To do this, copy and paste the following command into the Terminal and hit Return . [1]
    • cd /Library/Java/JavaVirtualMachines
  5. 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.
  6. 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.
  7. 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.
  8. Advertisement
Section 4 of 4:

Removing the Java Deployment Cache

PDF download Download Article
  1. 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 .
  2. 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 .
  3. 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.
  4. Advertisement

Expert Q&A

Ask a Question
      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.
      • 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 .
      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.

      Is this article up to date?

      Advertisement