If you are sure that you have set them properly, you can print your environment variables like JAVA_HOME using any of the below methods in Windows 10.


  1. Windows Command prompt ( cmd.exe )

    C:\>echo %JAVA_HOME%
    C:\Program Files\Java\jdk1.7.0_80
    

  1. Git Bash within windows, you need to use the bash format

    user12231@TP-UN103 MINGW64 /c
    $ echo $JAVA_HOME
    C:\Program Files\Java\jdk1.7.0_80
    

  1. From the conversation, it looks like you are using Windows 10 powershell.
    To print the environment variable in windows powershell, use one of the following commands as below

    PS C:\>Get-ChildItem Env:JAVA_HOME
    
    Name                           Value
    ----                           -----
    JAVA_HOME                      C:\Program Files\Java\jdk1.7.0_80
    

    or

    PS C:\> echo $env:JAVA_HOME
    C:\Program Files\Java\jdk1.7.0_80
    

    You can refer the Powershell documentation here.

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-6#displaying-environment-variables


Answer from sr56 on Stack Overflow
Top answer
1 of 12
83

If you are sure that you have set them properly, you can print your environment variables like JAVA_HOME using any of the below methods in Windows 10.


  1. Windows Command prompt ( cmd.exe )

    C:\>echo %JAVA_HOME%
    C:\Program Files\Java\jdk1.7.0_80
    

  1. Git Bash within windows, you need to use the bash format

    user12231@TP-UN103 MINGW64 /c
    $ echo $JAVA_HOME
    C:\Program Files\Java\jdk1.7.0_80
    

  1. From the conversation, it looks like you are using Windows 10 powershell.
    To print the environment variable in windows powershell, use one of the following commands as below

    PS C:\>Get-ChildItem Env:JAVA_HOME
    
    Name                           Value
    ----                           -----
    JAVA_HOME                      C:\Program Files\Java\jdk1.7.0_80
    

    or

    PS C:\> echo $env:JAVA_HOME
    C:\Program Files\Java\jdk1.7.0_80
    

    You can refer the Powershell documentation here.

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-6#displaying-environment-variables


2 of 12
36

There is high possibility that you used the Windows10 PowerShell terminal unknowingly instead of the standard windows command prompt.

In a standard Windows command prompt, when you type the below command, you would get the JAVA_HOME path as expected.

echo %JAVA_HOME%

Upon issuing the same command in PowerShell you would see %JAVA_HOME% written out.

PowerShell does things differently. In this case to output environment variables, you need to use

echo $env:JAVA_HOME

Additional tip: To print all environment variables dictionary use

dir env:
🌐
Planetary Data System
pds.nasa.gov › datastandards › training › documents › Finding and Setting JAVA HOME.pdf pdf
Finding and Setting JAVA HOME
that would be too easy. So if JAVA_HOME isn't already set, your next task is to find the directory to ... If your Java version is fairly recent, there's a useful command option that lists out a whole bunch of · system property settings, including the value of java.home, which is what we need.
🌐
Baeldung
baeldung.com › home › java › how to find java_home
How to Find JAVA_HOME | Baeldung
January 28, 2026 - If JAVA_HOME is defined in our environment, then the above command will print it out. ... This probably just shows us /usr/bin/java, which really isn’t very helpful since it’s a symbolic link. To unravel this, we’ll use dirname and readlink. ... This command prints the currently used java folder.
🌐
TechBloat
techbloat.com › home › how to check java home in cmd
How to Check Java Home in CMD - TechBloat
March 1, 2026 - Follow these straightforward steps to check JAVA_HOME in Windows Command Prompt. Press Windows + R, type cmd, and press Enter. This opens the Command Prompt window. ... This command displays the current value of the JAVA_HOME variable. If it shows a valid directory path, JAVA_HOME is set correctly.
Top answer
1 of 3
2

Your $JAVAHOME is pointing to the correct location. But the path should have $JAVAHOME/bin directory and not $JAVAHOME itself.

JAVA_HOME="/opt/jdk1.7.75"
export JAVA_HOME
PATH="$PATH:$JAVA_HOME/bin"

You should consider using the Oracle Java PPA instead. It usually does more than what a manual installation would do. You don't have to worry about setting up the environment variables either. That's what most people use.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Try running java -version and javac -version to verify that the path is set.

2 of 3
0

If you have update-java-alternatives installed, just type

$>update-java-alternatives -l

From the manual man update-java-alternatives

DESCRIPTION update-java-alternatives updates all alternatives belonging to one runtime or development kit for the Java language. A package does provide these information of it's alter‐ natives in /usr/lib/jvm/..jinfo.

OPTIONS -l|--list [] List all installed packages (or just ) providing information to set a bunch of java alternatives. Verbose output shows each alternative provided by the pack‐ ages.

If you don't have it installed, simply run

$>ls -l /usr/bin/java

It should return a pointer to the java bin file, something like

$>ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 ott 16  2013 /usr/bin/java -> /usr/lib/jvm/java-8-oracle/jre/bin/java

JAVA_HOME is the part previous to jre, so in my case /usr/lib/jvm/java-8-oracle

🌐
Wikihow
wikihow.com › computers and electronics › software › programming › java › how to set java_home on windows, linux, & mac
How to Set JAVA_HOME on Windows, Linux, & Mac
March 5, 2025 - You can also open the command prompt and run the command wmic product where "Name like '%%Java%%'" get installlocation,Name. This will tell you the full path of the JDK, even if you haven't yet set JAVA_HOME.
🌐
TechBloat
techbloat.com › home › how to check java path in cmd
How to Check Java Path in CMD - TechBloat
March 1, 2026 - Locate the Path variable, click Edit, and add %JAVA_HOME%\bin at the end of the list. Click OK on all windows to save changes. Close and reopen CMD to refresh environment variables. Type java -version again. If the path is correct, you’ll see your Java version info without errors.
Find elsewhere
🌐
Medium
medium.com › @aleksej.gudkov › how-to-get-openjdk-java-home-path-in-linux-macos-and-windows-0e4da01b595b
How to Get OpenJDK Java Home Path in Linux, macOS, and Windows | by UATeam | Medium
November 24, 2024 - Alternatively, if java_home is unavailable, you can use the following method: ... This command will locate the path of the Java binary and remove the bin/java portion, leaving you with the JAVA_HOME directory.
🌐
Super User
superuser.com › questions › 1733840 › how-to-properly-find-java-home-folder-with-batch
cmd.exe - How to properly find java home folder with batch? - Super User
I probably should mention that I also tried the java -XshowSettings:properties -version 2>&1 | findstr "java.home" but the format of that output string doesn't give much options to get just the path. ... @echo off & setlocal for /F tokens^=2* %%A in (' reg query "HKLM\SOFTWARE\JavaSoft\JDK" /v "CurrentVersion" ')do set "_java_version=%%~B" echo C:\Program Files\Java\jdk-%_java_version% for /F tokens^=2* %%A in (' reg query "HKLM\SOFTWARE\JavaSoft\JDK\%_java_version%" /v "JavaHome" ')do set "_java_home=%%~B" echo %_java_version% & echo "%_java_home%" endlocal & pause
🌐
The Windows Club
thewindowsclub.com › the windows club › general › how to set java_home in windows 11/10
How to set JAVA_HOME in Windows 11/10
Now go back to the Environment Variable window and select Path under the System variable. Click on Edit button to open Edit environment variable window. Click on New button and type %JAVA_HOME%\bin.
Published   July 13, 2024
🌐
TheServerSide
theserverside.com › feature › How-to-set-JAVA_HOME-in-Windows-and-echo-the-result
How to set JAVA_HOME in Windows | TheServerSide
Remember that JAVA_HOME points to the root folder into which the JDK was installed. Do not point JAVA_HOME to the \bin directory of the install. The PATH variable points to \bin, while JAVA_HOME points to the root folder into which the JDK was installed.
🌐
Controlyourmindset
controlyourmindset.com › posts › f9db4adcbb1853f4c7aab6cda723492f
How can I check Java path in CMD? – Control Your Mindset
Open a Command Prompt window (Win⊞ + R, type cmd, hit Enter). Enter the command echo %JAVA_HOME% . This should output the path to your Java installation folder. If it doesn’t, your JAVA_HOME variable was not set correctly. ... Right click on My Computer and go to properties (or) Press Windows ...
🌐
LinuxConfig
linuxconfig.org › home › how to locate and set java home directory on linux
How to locate and set JAVA home directory on Linux
June 6, 2023 - Another way to determine the Java home directory is by using a combination of the dirname and other commands below. This works by uncovering the root directory for the javac executable. $ dirname $(dirname $(readlink -f $(which javac))) /usr/lib/jvm/java-19-openjdk-amd64 · Yet another way would be to check the path for your java command.
🌐
javathinking
javathinking.com › blog › how-to-find-java-home
How to Find JAVA_HOME — javathinking.com
In the "System Variables" section ... to your JDK installation. Open the Command Prompt. You can do this by pressing Win + R, typing cmd, and hitting Enter....
🌐
Java With Us
javawithus.com › home › faq › how to check java version in command prompt (windows)
How to Check Java Version in Command Prompt (Windows) | Java With Us
April 21, 2026 - Open cmd and run java -version. If it fails, Java is not on PATH. Here is how to diagnose, fix PATH, and check the JAVA_HOME variable.
🌐
Quora
quora.com › How-do-you-check-if-the-Java-path-is-correct-in-Windows
How to check if the Java path is correct in Windows - Quora
Answer: You need to set JAVA_HOME system environemtn variable You need to set path and classpath as well. Windows 7 – Right click My Computer and select Properties > Advanced Windows 8 – Go to Control Panel > System > Advanced System Settings Windows 10 – Search for Environment Variables ...
🌐
Baeldung
baeldung.com › home › java › set java_home variable in windows, mac os x, and linux
Set JAVA_HOME on Windows 7, 8, 10, Mac OS X, Linux | Baeldung
March 26, 2025 - Set JAVA_HOME as the Variable name, and the path to the JDK installation as the Variable value, and click OK. Click OK and then Apply to apply the changes. Open Command Prompt and check the value of the JAVA_HOME variable:
🌐
Atlassian Confluence
confluence.atlassian.com › display › DOC › Setting+the+JAVA_HOME+Variable+in+Windows
Setting the JAVA_HOME Variable in Windows | Confluence Data Center 10.2 | Atlassian Documentation
Set the value of the environment variable to your JDK (or JRE) installation path as follows: setx /m JAVA_HOME "C:\Program Files\Java\jdk11.0.17.8" Restart Command Prompt to reload the environment variables then use the following command to check the it's been added correctly.