Step 1:
First go to download the java pack using this link.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Step 2:
Download the pack and right click to install, default path location is
"C:\Program Files\Java\jdk1.8.0_xx"
Step 3:
Now go to Advanced system settings in control panel and select advanced tab
Or
Select Windows key + break key and select advanced system setting in left side panel
Step 4:
Now select environment variables in advanced tab
Step 5:
Click new in local system variables and then type,
variable name : path
variable value : c:\Program Files\Java\jdk1.8.0_xx\bin;
Now click OK button and close the system variables.
Step 6:
Now you have to check "Javac" command in command prompt if u get messages without error now java is working fine.