title: Store eval output in variable
body: <p>I'm new to Bash and trying to store eval command output in a variable. This is my code to check Java version:</p>
  
  <pre><code>javaPath="/opt/Java/i386/jre1.8.0_181/bin/Java -version"
  output=eval $javaPath
  echo "Java version is: $output"
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>java version "1.8.0_181"
  Java(TM) SE Runtime Environment (build ...)
  Java HotSpot(TM) 64-Bit Server ...
  Java version is:
  </code></pre>
  
  <p>Question: how can I store command output in <code>$output</code>?</p>