I had difficulties to make it works on Mountain Lion, because I had only Oracle Java 1.7 JDK installed.
So I downloaded and installed JAVA 1.6 from connect.apple.com. Then I modified the script...