echo %JAVA_HOME% returns %JAVA_HOME%

gaming with yoty picture gaming with yoty · Jul 9, 2018 · Viewed 53.7k times · Source

When I do

echo %JAVA_HOME% 

it returns %JAVA_HOME% on windows 10 what did I do wrong?

Answer

sr56 picture sr56 · Oct 15, 2018

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://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-6#displaying-environment-variables