title: How to fetch Java version using single line command in Linux
body: <p>I want to fetch the Java version in Linux in a single command. </p>
  
  <p>I am new to awk so I am trying something like </p>
  
  <pre><code>java -version|awk '{print$3}'  
  </code></pre>
  
  <p>But that does not return the version.  How would I fetch the <code>1.6.0_21</code> from the below Java version output?</p>
  
  <pre><code>java version "1.6.0_21"
  Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
  Java HotSpot(TM) 64-Bit Server VM (build 17.0-b16, mixed mode)
  </code></pre>