title: run a executable jar file within java program using class loaders
body: <p>I have heard that you could run other java files using Process or using ClassLoaders.</p>
  
  <p>I have a executable jar 'test.jar' with a main class called <code>Test</code>.</p>
  
  <p>I found a way to run using Process. I need to know how to do it using ClassLoaders.</p>
  
  <pre><code>Process p = Runtime.getRuntime().exec("java -jar test.jar");
  BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
  synchronized (p) {
     p.waitFor();
  }
  int b=0;
  while((b=bis.read()) &gt;0){
     System.out.print((char)b);    
  }
  </code></pre>