How to install JDK 7 on Yosemite (10.10)

To install it follow these steps:

  1. Download JDK 7
  2. Open the DMG
  3. Run pkgutil --expand "/Volumes/JDK 7 Update 60/JDK 7 Update 60.pkg" "/tmp/JDK 7 Update 60.unpkg"
  4. Go to /tmp/JDK 7 Update 60.unpkg
  5. Open the Distribution file in your favorite editor (I recommend (Sublime Text)[])
  6. Change the function pm_install_check() to always return true
  7. Run pkgutil --flatten "/tmp/JDK 7 Update 60.unpkg" "/tmp/JDK 7 Update 60.pkg"
  8. Run open "/tmp/JDK 7 Update 60.pkg"

The installer should skip the OS version check and you should be able to install without any problems.