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_80or
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
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_80or
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
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:
Videos
I need help finding the location of my java_home/bin
"Start" > "Control Panel" > "Java".
Select "Java" tab.

Click "View"
Look in the "Path" column for version of the JRE you have installed.

In the above example the "Path" contains:
C:\apps\jdk\jre\bin\javaw.exe
JAVA_HOME should point to the root directory of the Java installation,
so in this case:
C:\apps\jdk
And the PATH should contain JAVA_HOME\bin, in this case:
C:\apps\jdk\bin
From a command prompt we can set these values using the following commands:
setx JAVA_HOME C:\apps\jdk
setx PATH C:\apps\jdk\bin;%PATH%
Notes:
- Modify the above commands as appropriate for your Java installation.
- These are
SystemnotUserenvironment variables.
See Installing the JDK Software and Setting JAVA_HOME and PATH and CLASSPATH for more information.
On your keyboard click the windows key and q and search java. Then in the apps section next to about java click the arrow and click open file location. You are here at the file location
If this does not work for you you maybe don't have windows or you have an old version of it or if you have windows and the latest version of windows then I don't know what is wrong.
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.
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
On Linux you can run $(dirname $(dirname $(readlink -f $(which javac))))
On Mac you can run $(dirname $(readlink $(which javac)))/java_home
I'm not sure about windows but I imagine where javac would get you pretty close
Just another solution, this one's cross platform (uses java), and points you to the location of the jre.
java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home'
Outputs all of java's current settings, and finds the one called java.home.
For windows, you can go with findstr instead of grep.
java -XshowSettings:properties -version 2>&1 | findstr "java.home"