Lets see how you can set Java_Home Environment variable for Windows Operating systems,
Step 1. Find-out where JRE has been installed
Once you install JRE you need to locate where java has been installed on your system. And the folder that you need to look for is Program Files
Note : If you have a 64-bit Windows Operating system installed then you will have 2 program files folders under C:/
1. Program Files
2. Program Files(x86)
If you find the Java folder under "Program Files(x86)" then the installed java version is 32-bit, if you find it under "C:/Program Files/Java" means Java version is 64-bit.
Look that you can see jre6 folder under java directory, i.e. : C:/Program Files/Java/jre6 or C:/Program Files(86)/Java/jre6
Step 2. Setting-up JAVA_HOME
1. Right Click on My Computer icon and select Properties option and Select Advance tab.
2. Now look for Environment Variable button and Click on it.
3. Now look for System Variables and click on New,
4. Add Variable name => JAVA_HOME and Variable value => C:/Program Files/Java/jre7 or C:/Program Files(86)/Java/jre7
5. Click OK and Apply Changes.
For Windows 7
1. Go to Start menu and select Computer
2. Select System Properties from the context menu
3. Now click on Advanced system settings and go to Advanced tab
4. Now click on Environment Variables
5. Under System Variables look for PATH.
6. Modify PATH by adding the location of the class to the value for PATH.
7. Reopen Command prompt window, run your java code, if the code works, path is been set correctly.
Setting JAVA_HOME using Eclipse
You can set the java environment variable in eclipse by going to,
Eclipse -> Window -> Preferences -> Java -> Installed JREs
Now here you can search for the location where the JRE is been installed and select it.