Removing Java from OS X Lion

OS X Lion ships without Java now. Installing it is not very difficult - however, our product relies on Java so we need to test the scenario of not having Java installed.

Once I've installed Java, is there any way to uninstall it from Lion?


Solution 1:

I followed the instructions followed in this blog and they worked for me.

The steps are as follows:

  1. Check for Java Installation: sudo /usr/libexec/java_home -xml (an output with two JVM dictionaries confirms that Java is installed)
  2. Run uninstaller: sudo /usr/libexec/java_home –uninstall
  3. Remove JVM installation location: sudo rm -rf /System/Library/Java
  4. Run command from step 1 again. If you receive an output starting with "Unable to find any JVMs matching version", this confirms that Java is no longer installed.

Solution 2:

I don't know about uninstalling Java, but since Lion now permits virtualization another option is just to run another instance of Lion in a VM and don't install Java on it. This can also be used to test other configurations that you might run into.

Solution 3:

You could always just make a clean install of Lion for test purposes, either on an extra partition or in virtualization.

You could also use the Java .pkg file to obtain a list of installed files.