Programmatically compile Java class : JavaCompiler « Development Class « Java






Programmatically compile Java class

 
import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;

public class Main {
  public static void main(String[] args) {
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    int result = compiler.run(null, null, null, "Hello.java");

    System.out.println("Compile result code = " + result);
  }
}
 

 








Related examples in the same category