I'm curious about the difference that exists between the paths that I see in the windows environment to java.
If I do a command where java
I can see
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
C:\ProgramData\Oracle\Java\javapath\java.exe
C:\Program Files\Java\jdk1.6.0_21\bin\java.exe
And I have seen that the first one, the javapath, gets updated with the latest java sdk I have installed. However, most of what you google tells you should set the environment variable PATH to the latest, the one with the jdk in the path. So what is the best, how do they work. For example, what's best for Xamarin or Android development?
Hopefully someone has some insight, I'd appreciate comments on this. Now I know, (everyone does) that to change the path to java you have to set the JAVA_HOME variable. I did this after posting this, it's hard to recall everything you read at any given moment! Still what's the purpose of the other paths, and why does updating java jre automatically sets the java version while downloading an sdk requires a manual update?
JAVA_HOME and JRE_HOME are not used by Java itself. Some third-party programs (for example Apache Tomcat) expect one of these environment variables to be set to the installation directory of the JDK or JRE. If you are not using software that requires them, you do not need to set JAVA_HOME and JRE_HOME.
Open 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.
When a new version of JRE is installed, this path C:\Program Files (x86)\Common Files\Oracle\Java
appears to be updated with executables corresponding to the new JRE version. The problem is this would be JRE and not JDK. So, programs that depend on JDK (IDE for example) will fail to launch.
Here is how I get it to work consistently
JAVA_HOME
pointing to the JDK Home. And add %JAVA_HOME%\bin
to the PATH
environment variable.C:\Program Files (x86)\Common Files\Oracle\Java\javapath
from the Path
environment variable in System Environment Variables (Control Panel -> System -> Advanced System Settings -> Environment Variables -> System Variables).This works as of Aug 2020 for Windows 10 (1903), Java 8u251. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With