Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
    
What does type java and ls $(type -p java) return? –  patrix Dec 8 '12 at 10:03
    
type java—>java is /usr/bin/java. ls $(type -p java)—>/usr/bin/java –  remac Dec 8 '12 at 22:40
    
Similar, with an accepted answer and plenty of votes: Uninstalling Java on Lion –  Graham Perrin Feb 2 '13 at 19:28
add comment

1 Answer

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.

share|improve this answer
    
might want to include rm -rf /private/var/db/receipts/com.apple.pkg.JavaTools.{bom,plist} –  naomik Oct 16 '13 at 6:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.