title: Get Java Version using `Runtime.getRuntime().exec(commands)`
body: <p>I found, we can find out Java version using <code>System.getProperty("java.version")</code>.
  from here - <a href="https://stackoverflow.com/questions/2591083/getting-version-of-java-in-runtime">Getting Java version at runtime</a></p>
  
  <p>But I have already done so coding using <code>Runtime.getRuntime().exec(commands)</code> -</p>
  
  <pre><code>String[] commands ={"java", "-version"};
      String line;
      String cmdOutput = "";
      try {
          Process process = Runtime.getRuntime().exec(commands);
          process.waitFor();
          BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
          while ((line = input.readLine()) != null) {
              cmdOutput += (line + "\n");
          }
          System.out.println("output "+cmdOutput);
          input.close();
          }
      catch (Exception ex) {
          ex.printStackTrace();
      }
  </code></pre>
  
  <p>But getting blank output.</p>
  
  <p>When I run <code>java -version</code> from command prompt, we get version, I feel it should also return same output.</p>
  
  <p>Before I discard it and use <code>System.getProperty("java.version")</code>, Can I please know what I am missing here ? </p>
  
  <p>Thanks in advance.</p>