I note to begin with that a very related question has been asked before, but the answer was to restart the system which does not work for me. Here is that link if anyone is interested:
WINDOWS 10 JAVA_HOME is not working
Also, there are several similar discussions about Path, and the answers seem to involve the order in which entries appear in the path, or a registry reset, however that does not appear to be the case here, since my working and non-working solution use the same order and the same registry settings. I did not list these since there are several.
But my case is that I have set JAVA_HOME:
And then I have used JAVA_HOME in Path (at the bottom, not the top):
And then javac -version fails at the command line:
But if I replace JAVA_HOME with its exact contents in Path:
Then javac -version works:
So, seemingly a pointless question since I can make it work. However, I am wondering why partly in the interest of knowing what is going on and partly in the interest of knowing if JAVA_HOME will fail if used elsewhere.