i tried your suggestion and it displays \Common was not expected
Copiar do console:
C:\tmp>del test.bat
C:\tmp>copy con test.bat
@echo off
for /f %%j in ("java.exe") do (
set JAVA_HOME=%%~dp$PATH:j
)
if "%JAVA_HOME%"=="" (
@echo Java.exe not found
@echo Please make sure that java JDK 1.7 or 1.8 is installed
) else (
@echo Java.exe exists in "%JAVA_HOME%"
)
^Z
Files copied: 1.
C:\tmp>test
Java.exe exists in "C:\Program Files (x86)\Common Files\Oracle\Java\javapath\"
Emular a ausência - JAVA.EXE substituído por ZZZ.EXE:
C:\tmp>del test.bat
C:\tmp>copy con test.bat
@echo off
for /f %%j in ("ZZZ.exe") do (
set JAVA_HOME=%%~dp$PATH:j
)
if "%JAVA_HOME%"=="" (
@echo Java.exe not found
@echo Please make sure that java JDK 1.7 or 1.8 is installed
) else (
@echo Java.exe exists in "%JAVA_HOME%"
)
^Z
Files copied: 1.
C:\tmp>test
Java.exe not found
Please make sure that java JDK 1.7 or 1.8 is installed
C:\tmp>