The first time I tried to use Java on Mountain Lion, it installed automatically. Unfortunately, it installed Java 6, so I installed Java 7. If I navigate to Java in System Preferences, only Java 7 is listed. How do I switch to Java 7, or remove Java 6?
Apple's tools don't see Java 7, Oracle's tools don't see Java 6; it's all a bit ugly. Luckily there's an ugly fix to go with it!
Normal Mac Java 6 running on 10.8:
Install the Java 7 JDK (not just the JRE) from Oracle.
Move the system java out of the way (so you can get it back if you want):
Then symlink 7 in place of 6:
I've not had trouble with any java apps so far (apart from java preferences which checks which java it's running under).
There's probably a better way of doing this, but it works for me.
$ cp -r /Library/Java/JavaVirtualMachines/jdk1.7.0_12.jdk /System/Library/Java/JavaVirtualMachines/
$ sudo ln -sF /System/Library/Java/JavaVirtualMachines/jdk1.7.0_12.jdk CurrentJDK
$ java -version java version "1.7.0_12-ea" Java(TM) SE Runtime Environment (build 1.7.0_12-ea-b05) Java HotSpot(TM) 64-Bit Server VM (build 24.0-b26, mixed mode)
To switch to Java 7 for when Java is run from the terminal, I added the following line to