Here's how to set JAVA_HOME in Windows 7 |Video upload date:  · Duration: PT18S  · Language: EN

Quick guide to set JAVA_HOME on Windows 7 and add Java to PATH so java commands run from the command prompt

Quick summary for the impatient

If you want command line Java tools to stop sulking and actually run, set a system variable named JAVA_HOME that points to your JDK root and add its bin folder to your PATH. This works on Windows 7 and keeps java version chaos to a minimum.

Step 1 Find your Java installation

Open Explorer and look under Program Files\Java for a folder named jdk followed by a version number such as jdk1.8.0_xxx. Prefer a JDK folder rather than a JRE folder so compilers and other developer tools behave themselves.

Step 2 Create or update JAVA_HOME

Go to Control Panel then System then Advanced system settings then Environment Variables. In the System variables section click New if JAVA_HOME is not present or Edit if it already exists. Set the value to the full path of the JDK root for example Program Files\Java\jdk1.8.0_251 or a similarly named folder on the C drive.

Why a system variable and not a user variable

System variables apply to all users and to services that may invoke Java. If you only set a user variable some tools might still pick up the wrong Java and then blame you for their existential crisis.

Step 3 Add the JDK bin to PATH

Edit the system PATH and add %JAVA_HOME%\bin as a new entry or append it to the existing string using the standard Windows path separator. Putting %JAVA_HOME%\bin near the front ensures the JDK you just pointed to is the one command line tools find first.

Step 4 Verify in a new command prompt

Close any open command prompt windows and open a fresh one. Then run these commands to confirm everything is sane.

java -version
echo %JAVA_HOME%

Troubleshooting tips that actually help

  • If java -version shows a different JDK check for multiple Java installs and make sure PATH does not contain another Java path before %JAVA_HOME%\bin.
  • If echo %JAVA_HOME% is empty you probably edited the wrong variable type or forgot to click OK and reopen the command prompt.
  • If a tool still acts up try restarting the machine so services pick up the new environment variables.

Extra tips for the control freaks

  • Give each JDK folder a clear name if you keep several versions. That makes it painless to switch JAVA_HOME when someone demands an older compiler.
  • Use the JDK not the JRE unless you are only running user apps and love missing tooling.

There you go. You found the JDK folder adjusted environment variables and verified the change from the command prompt. If the command line still complains go hunting for stray Java installs and remember to open a new session after making changes.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.