I need to write a batch script to find out if Java is installed, and if it is, then under what path? I feel it has to be something similar to this:
for /f %%j in ("java.exe") do (
set JAVA_HOME=..........
)
but I can not figure it out.
P.S. It has to work with path with spaces two. Like if java is installed into "Program Files".
Thanks.
JAVA_HOMEis only used by the JDK. Its absence doesn't tell you anything about whether a JRE is installed. Andjava.exeis part of both ...