Reputation: 1999
I've always been under the impression that the default Java is determined by searching for the first Java executable that can be found in one of the given directories in the PATH system environment variable.
Now, when I use java -version
on command line some Java on my system is called and shows version information even though no Java-path is on the PATH system environment variable.
So how does the command line decide what Java to use? I.e. where can this be configured?
Upvotes: 0
Views: 582
Reputation: 35407
There are a java.exe
, a javaw.exe
and a javaws.exe
in your C:\Windows\System32\
folder.
Usually, that one is taken because it's before any other jdk/jre folder that you use.
You can check which java
is taken by typing where java
in your prompt. This will list all the java
executables in order of appearance in your %PATH%
.
Upvotes: 3
Reputation: 8278
It is taken from the registry. Java executable uses it to locate the default version of Java to run.
The copy of java.exe to run is found by using the PATH environment variable. If you do not change this, by default a copy will be found in the Windows directory.
You can modify the registry, or put the version of Java you want before the Windows directory in your PATH.
Upvotes: 0