echo %JAVA_HOME% returns %JAVA_HOME%

We Are Going To Discuss About echo %JAVA_HOME% returns %JAVA_HOME%. So lets Start this Java Article.

echo %JAVA_HOME% returns %JAVA_HOME%

  1. echo %JAVA_HOME% returns %JAVA_HOME%

    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.

  2. echo %JAVA_HOME% returns %JAVA_HOME%

    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.

Solution 1

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

    [email protected] 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


Original Author sr56 Of This Content

Solution 2

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:

Original Author Priyesh Diukar Of This Content

Solution 3

The syntax depends on the shell/terminal you are using.
Try

echo $JAVA_HOME

this is the syntax for bash, for instance if you are using Git Bash to run your commands.

Original Author Matsemann Of This Content

Solution 4

If you just added the System Variable you need to reboot for System to read it

if you are using an classic cmd command “echo %JAVA_HOME%” in windowsJAVA is fine

Original Author Kiki Risager Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment