Check availability of JRE
Open Command Prompt (cmd)
Type command:  java - version 
If you get an error,then the JDK may not be installed or it may not be in your path.
It is possible that you have the Java runtime (JRE), but not the JDK.
So, the javac program won't be found, but the  java - version  will print the JRE version number.
Check availability of JDK
Press  Window + R  key to open the Run dialog.
Type  cmd  at the prompt
Type command:  java - version  in Command Prompt.
The output will vary depending on which version is installed and which vendor provided the Java installation.
If you have installed the JDK, you should know that it comes equipped with JRE as well.
Setting up the path for Windows
Right-click on  'My Computer' 
Select  'Properties' 
Navigate to the  Advanced System Settings  tab on the top.
Select  Environment Variables 
In the Edit System Variable dialog, go to the Variable value field. This field is a list of directory.
To add a  new  path, append the location of your JDK bin folder
Click OK on every opened dialog to save changes.
Setting up the path for Linux
Right-click on  'My Computer' 
Select  'Properties' 
Navigate to the  Advanced System Settings  tab on the top.
Select  Environment Variables 
In the Edit System Variable dialog, go to the Variable value field. This field is a list of directory.
To add a  new  path, append the location of your JDK bin folder
Click OK on every opened dialog to save changes.
Setting up the path for UNIX
Right-click on  'My Computer' 
Select  'Properties' 
Navigate to the  Advanced System Settings  tab on the top.
Select  Environment Variables 
In the Edit System Variable dialog, go to the Variable value field. This field is a list of directory.
To add a  new  path, append the location of your JDK bin folder
Click OK on every opened dialog to save changes.
Setting up the path for Solaris
Right-click on  'My Computer' 
Select  'Properties' 
Navigate to the  Advanced System Settings  tab on the top.
Select  Environment Variables 
In the Edit System Variable dialog, go to the Variable value field. This field is a list of directory.
To add a  new  path, append the location of your JDK bin folder
Click OK on every opened dialog to save changes.