echo %JAVA_HOME% returns %JAVA_HOME%
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.
-
Windows Command prompt ( cmd.exe )
C:\>echo %JAVA_HOME% C:\Program Files\Java\jdk1.7.0_80
-
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
-
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 belowPS 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.
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:
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.
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
Solution 5
Your command is correct for a windows 10 machine. And the result tells us, that this variable is not set. You can look for the settings for the environment variables in your start menu. You'll see settings for other variables like Path, TEMP and so on. There you can add JAVA_HOME (here without %). The path would be like this (from my pc): C:\Program Files\Java\jdk1.8.0_161
gaming with yoty
Updated on January 25, 2022Comments
-
gaming with yoty over 2 years
When I do
echo %JAVA_HOME%
it returns
%JAVA_HOME%
on windows 10 what did I do wrong?