Setting Java_Home Environment variable on Windows Operating System

Prerequisite : You have installed Java Runtime Environment (any version jre6, jre7, or jre8)

Let's see how you can set the 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 the 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 the 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/Window 10/Windows 11

  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, and run your java code, if the code works, the path is been set correctly.
Edit the system environment variables - Windows 10
Search: Edit the system environment variables on Windows 10 and 11 to quickly edit Environment Variables.

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.

Try Out Code2care Dev Tools:


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.