io redirection - How To Pipe Java Version in Batch File -
how can find java version , set variable?
i've tried this:
for /f "tokens=*" %%a in ('java -version | find "version"') (set var1=%%a) but java isn't redirecting output find. post suggested solution
java -version 2>&1 | findstr "version" >tmp.txt /f "tokens=*" %%x in (tmp.txt) (set var1=%%x) echo %var1% del tmp.txt but avoid using temp file.
java.exe seems output version information @ stderr, correct code is:
for /f "tokens=*" %%a in ('java -version 2^>^&1 ^| find "version"') (set var1=%%a) as can see, >, & , | escaped ^.
Comments
Post a Comment