Java Checker is a tweaker mod that shows a user-friendly message if the user has outdated Java. There are currently two versions, one that checks for Java 7, and one for Java 8 - read the Installation Guide for more details. The mod is free to use, modify, redistribute or whatever else you might want to do. Usage in modpacks is welcome.
This will work for all versions of Minecraft since 1.6.2. If you need to know how to install the mod without Forge or for older versions, read the Special Requests section below.

The source code is available on GitHub: https://github.com/chylex/Java-Checker
External links: My website | Twitter | Patreon
Read a guide on shading Java Checker on its GitHub repository.
Download Java Checker v1.1, and install it into the coremods folder.
Java Checker is a tweaker mod, which allows you to modify the json file in your Minecraft launcher profile, and add --tweakClass chylex.javacheck.Java<version>Checker to minecraftArguments, and add Java Checker as a library. This is very much a theoretical scenario that has not been tested, so be careful.