I'm currently fighting with my IDE and usage of PATH, JAVE_HOME, etc. on Windows 7.
As stated in this question: PATH variable showing different values (command prompt vs environment variables dialog box) I've unfortunately copied my whole PATH (multiple time) in the user one using setx
.
But there is something I don't understand: if I do a echo %PATH%
, it seems that it prints the system path before the user one. However, it seems that when using the path, windows first search on the user one then the system.
I'm asking this because I'm trying to override the default JDK.
Example, when I do echo %path:;=&echo.%
(to print path with carriage return)
C:\Program Files (x86)\Java\jdk1.7.0_07\bin
c:\program files\apache-maven-3.5.0\bin
C:\Program Files (x86)\Java\jdk1.7.0_07\bin
c:\program files\apache-maven-3.5.0\bin
C:\Program Files (x86)\Java\jdk1.7.0_07\bin
c:\program files\apache-maven-3.5.0\bin
C:\WINDOWS\System32
C:\ProgramData\Oracle\Java\javapath
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
etc.
C:\Users\asoub\java\open_jdk_8u40\bin
C:\Program Files (x86)\Java\jdk1.7.0_07\bin
c:\program files\apache-maven-3.5.0\bin
C:\Program Files (x86)\Java\jdk1.7.0_07\bin
c:\program files\apache-maven-3.5.0\bin
C:\Program Files (x86)\Java\jdk1.7.0_07\bin
c:\program files\apache-maven-3.5.0\bin
C:\WINDOWS\System32
C:\ProgramData\Oracle\Java\javapath
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
But if I do java -version
, I get openjdk version "1.8.0_40"
. And to confirm this, if I print only user path with C:\Users\asoub>For /F "Skip=2Tokens=1-2*" %A In ('Reg Query HKCU\Environment /V PATH 2^>Nul') Do @Echo %A=%C
PATH=C:\Users\asoub\java\open_jdk_8u40\bin
C:\Program Files(x86)\Java\jdk1.7. 0_07\bin
c:\program files\apache-maven-3.5.0\bin
C:\Program Files (x86)\Java\jdk1.7.0_07\bin
c:\program files\apache-maven-3.5.0\bin
C:\Program Files (x86)\Java \jdk1.7.0_07\bin
c:\program files\apache-maven-3.5.0\bin
C:\WINDOWS\System32
C:\ProgramData\Oracle\Java\javapath
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\Program Files\SafeNet\Aut
The java binary file is of course in java\...\bin
. The first folder read by Windows when using java -version
is the first one from the user path, not the first one from the global path. But when the full path is printed, the first folder with a java executable shown is jdk 1.7.0 ...
So, does Windows echo the path: System first, user second, but uses it user first, system second?
where java
.