code: private String getJavaExecutable() throws IOException {
      String javaCommand = "java" + (Os.isFamily(Os.FAMILY_WINDOWS) ? ".exe" : "");
  
      String javaHome = System.getProperty("java.home");
      File javaExe;
      if (Os.isName("AIX")) {
        javaExe = new File(javaHome + File.separator + ".." + File.separator + "sh", javaCommand);
      } else if (Os.isName("Mac OS X")) {
        javaExe = new File(javaHome + File.separator + "bin", javaCommand);
      } else {
        javaExe = new File(javaHome + File.separator + ".." + File.separator + "bin", javaCommand);
      }
  
      // ----------------------------------------------------------------------
      // Try to find javaExe from JAVA_HOME environment variable
      // ----------------------------------------------------------------------
      if (!javaExe.isFile()) {
        Properties env = CommandLineUtils.getSystemEnvVars();
        javaHome = env.getProperty("JAVA_HOME");
        if (StringUtils.isEmpty(javaHome)) {
          throw new IOException("The environment variable JAVA_HOME is not correctly set.");
        }
        if (!new File(javaHome).isDirectory()) {
          throw new IOException("The environment variable JAVA_HOME=" + javaHome
              + " doesn't exist or is not a valid directory.");
        }
  
        javaExe = new File(env.getProperty("JAVA_HOME") + File.separator + "bin", javaCommand);
      }
  
      if (!javaExe.isFile()) {
        throw new IOException("The java executable '" + javaExe
            + "' doesn't exist or is not a file. Verify the JAVA_HOME environment variable.");
      }
  
      return javaExe.getAbsolutePath();
    }
docs: Get the path of the java executable: try to find it depending the
  OS or the <code>java.home</code> system property or the
  <code>JAVA_HOME</code> environment variable.
  
  @return the absolute path of the java executable
  @throws IOException
  if not found