Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

echo %JAVA_HOME% returns %JAVA_HOME%

When I do

echo %JAVA_HOME%  

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

like image 436
gaming with yoty Avatar asked Jul 09 '18 10:07

gaming with yoty


People also ask

What is echo $Java_home?

The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed. This variable should be configured on all OS's that have a Java installation, including Windows, Ubuntu, Linux, Mac and Android.

How do you check JAVA_HOME is set or not?

Verify JAVA_HOMEOpen 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.

What should be the value of JAVA_HOME?

To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1. 6.0_02.


2 Answers

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


like image 143
sr56 Avatar answered Sep 17 '22 22:09

sr56


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: 
like image 41
Priyesh Diukar Avatar answered Sep 18 '22 22:09

Priyesh Diukar