title: How to get Java Version from batch script?
body: <p>I am trying to get '6' out of the java version output given below</p>
  
  <pre><code>java version "1.6.0_21"
  Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
  Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)
  </code></pre>
  
  <p>For the same I wrote this batch script</p>
  
  <pre><code>set VERSION6="1.6.0_21"
  java -version 2&gt;&amp;1 | findstr "version" &gt;ab.txt
  for /f "tokens=3" %%g in (ab.txt) do (
    if not %%g == %VERSION6% echo %%g
    echo %%g
  )
  </code></pre>
  
  <p><code>%%g</code> displays "1.6.0_21"</p>
  
  <p>May someone guide me to correct direction? I am not much familiar with <code>for /f</code>.</p>