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

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -