title: how can java catch exit code from inside java?
body: <p>my java code runs a main method that throws exit code.</p>
  
  <p>How can I catch that exit code and not stop the runtime?</p>
  
  <pre><code>        ConfigValidator.main(new String[] {"-dirs", SdkServiceConfig.s.PROPERTIES_FILE_PATH});
  </code></pre>
  
  <p>I thought to use </p>
  
  <pre><code>        ProcessBuilder builder = new ProcessBuilder(commands);
          Process process = builder.start();
          int waitFor = process.waitFor();
          int a = process.exitCode()
  </code></pre>
  
  <p>but how can i run this to run java code?</p>
  
  <p>I cannot change the code inside the "main" method</p>