7

How do I completely uninstall Java from Mountain Lion?

I wanted to run Minecraft so I followed the system promps and I think I installed Java 7 and then Java 6. I couldn't get Mincraft to work for other reasons so I deleted it and now I want to get rid of Java.

Not sure if it's relevant but typing "java -version" into Terminal gives me "java version "1.6.0_37" Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909) Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)"

Any help would be appreciated.

3
  • What does type java and ls $(type -p java) return?
    – nohillside
    Dec 8, 2012 at 10:03
  • type java—>java is /usr/bin/java. ls $(type -p java)—>/usr/bin/java
    – remac
    Dec 8, 2012 at 22:40
  • Similar, with an accepted answer and plenty of votes: Uninstalling Java on Lion Feb 2, 2013 at 19:28

2 Answers 2

7

Apple provides an automatic Java installer but no uninstaller so you can't remove Java once you've installed it without using an at-your-own-risk approach.

That being said this is how to get rid of java from a terminal session and a using a text editor:

sudo rm -rf /System/Library/Java/JavaVirtualMachines/
sudo rm -rf /Library/Java/JavaVirtualMachines/*.jdk
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefpane
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaEssentials.bom
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaEssentials.plist
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaForMacOSX107.bom
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaForMacOSX107.plist
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaMDNS.bom
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaMDNS.plist
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaSecurity.bom
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaSecurity.plist

At this point you need to edit the installation history to delete evidence you installed Java. I suggest backing up the file first. If you prefer a different text editor feel free to use it but do not use a word processor that puts formatting codes in the text file.

sudo cp /Library/Receipts/InstallHistory.plist ~/Desktop
sudo emacs /Library/Receipts/InstallHistory.plist

Search for entries that look like:

    <dict>
            <key>date</key>
            <date>2011-09-16T22:22:10Z</date>
            <key>displayName</key>
            <string>Java for Mac OS X 10.6 Update 5</string>
            <key>displayVersion</key>
            <string>1.0</string>
            <key>packageIdentifiers</key>
            <array>
                    <string>com.apple.pkg.JavaForMacOSX10.6Update5</string>
            </array>
            <key>processName</key>
            <string>Software Update</string>
    </dict>

also

    <dict>
            <key>date</key>
            <date>2013-01-15T11:42:35Z</date>
            <key>displayName</key>
            <string>Java for OS X 2012-006</string>
            <key>displayVersion</key>
            <string>1.0</string>
            <key>packageIdentifiers</key>
            <array>
                    <string>com.apple.pkg.JavaEssentials</string>
                    <string>com.apple.pkg.JavaForMacOSX107</string>
                    <string>com.apple.pkg.JavaSecurity</string>
                    <string>com.apple.pkg.JavaMDNS</string>
            </array>
            <key>processName</key>
            <string>Software Update</string>
    </dict>

and delete them. You may wish to check your work using diff:

diff -u ~/Desktop/InstallHistory.plist /Library/Receipts/InstallHistory.plist | less

or some other file comparison tool.

You can test that java is gone by running:

java -version

You should see a pop up asking to install Java again.

1
  • might want to include rm -rf /private/var/db/receipts/com.apple.pkg.JavaTools.{bom,plist}
    – user59610
    Oct 16, 2013 at 6:59
-1

According to Oracle's Doc:

Uninstalling the JDK

To uninstall the JDK, you must have Administrator privileges and execute the remove command either as root or by using the sudo(8) tool.

Navigate to /Library/Java/JavaVirtualMachines and remove the directory whose name matches the following format:

/Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdk

For example, to uninstall 8u6:

% rm -rf jdk1.8.0_06.jdk

Do 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.

You can review this at: http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A1096903

1
  • 1
    This does not uninstall Apple's Java just Java 7 or 8
    – mmmmmm
    May 12, 2014 at 16:22

Not the answer you're looking for? Browse other questions tagged .