When installing the latest JRE 7 on Windows, it no longer adds the command java
to the system path. So just calling java --version
in bat file fails in that case (despite that Java from java.com is installed).
What's a reliable way to find the java command installation directory in a windows bat file?
I've seen it in the following locations:
C:\Program Files\Java\jre6\bin\java.exe
C:\Program Files\Java\jre7\bin\java.exe
C:\Program Files (x86)\Java\jre7\bin\java.exe
- Not tried JRE 8 yet.
Note: if there are multiple, I 'd like the default (or the latest – I don't care).
Best Answer
If it is installed, ask windows where it is