Friday 26 July 2019

Windows ignores JAVA_HOME [Solved!!!] [System restart required : )]

Problem : 
Windows ignores JAVA_HOME [Solution that works, even in Windows 10!!!]

Cause : 
Actually, in windows, the java executable uses the windows registry to locate the default version of java to run.
The copy of java.exe to run is found by using the PATH environment variable.Unless step is taken to change this,by default a copy will be found in the windows directory.

Since this copy is not present in the java run-time directory, it locates one by looking at the registry.

Solutions :
1st Solution (recommended) : Put the version of Java that you want, before the Windows directory in your system PATH variable under Environment variables.

i.e. put %JAVA_HOME%\bin in first position of PATH variable. Also, perform below Solution. Do a system restart for the changes to take effect. Done!!!

2nd Solution : Remove the C:\ProgramData\Oracle\Java\javapath directory from the PATH variable or move it to the end. Do a system restart for the changes to take effect.

3rd Solution : Rename the java.exe, javaw.exe and javaws.exe in Windows/System32 folder. This makes them non-available and hence the JAVA_HOME variable gets referred. Do a system restart for the changes to take effect.

4th Solution (least recommended) : Modify the registry to point to the right path to java. Do a system restart for the changes to take effect.

Helpful notes:
a. Path to Environment variables is as below:
[Computer/Properties/Advanced System Settings/Environment Variables]

b. System PATH needs to be modified and not the User PATH environment variable

c. Moving the Entry related to the JDK in the PATH variable before Windows i.e. in the first position solves this issue as well.

Please let me know if you have any query..

No comments:

Post a Comment