Download and install the corresponding JDK version: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
After successful installation, go to Computer-Properties-Advanced Settings-Environment Variables.
Create a new environment variable: JAVA_HOME: the value is the installation path of JDK: C:/Java/jdk1.7.0_51
Create a new environment variable: Classpath: .;%JAVA_HOME%/lib/dt.jar;%JAVA_HOME%/lib/tools.jar. Please note the two small punctuation marks in front, comma and semicolon ",;"
Find the environment variable: path, and add the JDK Bin path after the path value: %JAVA_HOME%/bin.
Open the console and enter the command: javac. If the content shown in the figure below appears, the installation is successful: